' ) ) { // Move custom css to customizer if it exists. if ( ! empty( $options['custom_css'] ) ) { wp_update_custom_css_post( wp_get_custom_css_post() . PHP_EOL . wp_kses( $options['custom_css'], [ "\'", '\"' ] ) ); } $new_options = [ 'VERSION' => ABT_VERSION, 'citation_style' => [ 'kind' => $options['citation_style']['kind'] ?? 'predefined', 'label' => $options['citation_style']['label'] ?? 'American Medical Association', 'value' => $options['citation_style']['value'] ?? 'american-medical-association', ], // @deprecated 5.0.0 'display_options' => [ 'bib_heading' => $options['display_options']['bib_heading'] ?? '', 'bib_heading_level' => $options['display_options']['bib_heading_level'] ?? 'h3', 'bibliography' => $options['display_options']['bibliography'] ?? 'fixed', 'links' => $options['display_options']['links'] ?? 'always', ], ]; update_option( ABT_OPTIONS_KEY, $new_options ); } } add_action( 'admin_init', __NAMESPACE__ . '\refactor_options' ); /** * Adds link on the plugin page to the options page. * * @param string[] $links array of links. */ function add_options_link( array $links ): array { $url = admin_url( 'options-general.php?page=abt-options' ); $text = __( 'Plugin Settings', 'academic-bloggers-toolkit' ); return array_merge( $links, [ "$text" ] ); } add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), __NAMESPACE__ . '\add_options_link' ); /** * Adds donation link to the plugin meta. * * @param mixed[] $links The array having default links for the plugin. * @param string $file The name of the plugin file. */ function add_donate_link( array $links, string $file ): array { if ( plugin_basename( __FILE__ ) === $file ) { $links[] = sprintf( '♥ %s', 'https://donorbox.org/academic-bloggers-toolkit', __( 'Donate', 'academic-bloggers-toolkit' ) ); } return $links; } add_filter( 'plugin_row_meta', __NAMESPACE__ . '\add_donate_link', 10, 2 ); /** * Registers all scripts/styles used by this plugin. */ function register_scripts() { $deps = get_dependencies(); // // Editor. // register_script( 'editor', [ 'scripts' => $deps['editor'] ] ); register_script( 'editor-blocks', [ 'scripts' => $deps['editor-blocks'] ] ); register_script( 'editor-formats', [ 'scripts' => $deps['editor-formats'] ] ); register_script( 'editor-formats', [ 'scripts' => $deps['editor-formats'] ] ); register_script( 'editor-stores', [ 'scripts' => $deps['editor-stores'] ] ); register_script( 'editor-legacy', [ 'scripts' => $deps['editor-legacy'], 'styles' => [ 'abt-legacy-fonts', 'dashicons', ], ] ); // // Options Page. // register_script( 'options-page', [ 'scripts' => $deps['options-page'] ] ); // // Frontend. // register_script( 'frontend', [ 'scripts' => $deps['frontend'] ] ); register_script( 'frontend-legacy', [ 'scripts' => $deps['frontend-legacy'] ] ); // // Third party. // wp_register_style( 'abt-legacy-fonts', add_query_arg( [ 'family' => 'Roboto:300,400,500,700', 'subset' => 'cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese', ], '//fonts.googleapis.com/css' ), [], ABT_VERSION ); wp_register_script( 'codepen', '//assets.codepen.io/assets/embed/ei.js', [], ABT_VERSION, true ); wp_register_script( 'CSL', '//cdn.jsdelivr.net/gh/Juris-M/citeproc-js@1.1.214/citeproc.min.js', [], ABT_VERSION, true ); } add_action( 'wp_loaded', __NAMESPACE__ . '\register_scripts' ); /** * Adds an ajax nonce to pages that require it. */ function ajax_nonce() { ?>