citation_styles and add a
* link to the options page in the admin menu.
*/
public function __construct() {
$this->get_citation_styles();
add_action('admin_menu', array($this, 'add_options_page'));
}
/**
* Grabs the citation styles from the vendor array and saves them to
* $this->citation_styles
*/
private function get_citation_styles() {
include dirname(__FILE__).'/../../vendor/citationstyles.php';
$this->citation_styles = $citation_styles;
}
/**
* Sanitizes and saves the path to the custom CSL file.
*
* This function should receive a URL and produce a PATH if everything
* checks out. Otherwise, it should return an empty string.
*
* If the sanitation fails, a dismissable notice is sent to the user.
*
* @param [string] $url Unsanitized URL submitted with the form.
* @return [string] Sanitized PATH to the CSL file.
*/
private function check_custom_style_url($url) {
if (file_exists($url) && substr($url, -4) === '.csl' || $url === '') {
return $url;
}
$uploads = wp_upload_dir();
$file = $uploads['basedir'] . str_replace($uploads['baseurl'], '', $url);
if (file_exists($file) && substr($file, -4) === '.csl') {
return $file;
}
?>
check_custom_style_url((string)$_POST['citation_style_custom_url']);
}
$citation_style_style = $abt_options['citation_style']['style'];
$citation_style_prefer_custom = $abt_options['citation_style']['prefer_custom'];
$citation_style_custom_url = $abt_options['citation_style']['custom_url'];
if ($updated_custom_css) {
$abt_options['custom_css'] = stripslashes_deep($_POST['custom_css']);
}
$custom_css = isset($abt_options['custom_css']) ? $abt_options['custom_css'] : '';
if ($updated_display_options) {
$abt_options['display_options']['bibliography'] = esc_html($_POST['display_options_bibliography']);
$abt_options['display_options']['links'] = esc_html($_POST['display_options_links']);
$abt_options['display_options']['bib_heading'] = esc_html($_POST['display_options_bib_heading']);
$abt_options['display_options']['bib_heading_level'] = esc_html($_POST['display_options_bib_heading_level']);
}
$display_options_bibliography = isset($abt_options['display_options']['bibliography']) ? $abt_options['display_options']['bibliography'] : '';
$display_options_links = isset($abt_options['display_options']['links']) ? $abt_options['display_options']['links'] : '';
$display_options_bib_heading = isset($abt_options['display_options']['bib_heading']) ? $abt_options['display_options']['bib_heading'] : '';
$display_options_bib_heading_level = isset($abt_options['display_options']['bib_heading_level']) ? $abt_options['display_options']['bib_heading_level'] : '';
update_option('abt_options', $abt_options);
include dirname(__FILE__) . '/views/options-page.php';
}
}
new ABT_Options();