'' . esc_html__('Settings', 'add-anchor-links') . '', ); return array_merge($action_links, $links); } /** * Load scripts and styles * @since 1.0.0 * @since 1.0.1 ADD_ANCHOR_LINKS_DONT_LOAD_CSS */ function add_anchor_links_scripts() { // Don't load scripts if disabled by settings or by constant global $add_anchor_links_options; if ( defined( 'ADD_ANCHOR_LINKS_DONT_LOAD_CSS' ) && ADD_ANCHOR_LINKS_DONT_LOAD_CSS || $add_anchor_links_options['own_css'] ) { return; } if ( is_singular( add_anchor_links_post_types( true ) ) ) { wp_enqueue_style('add-anchor-links-style', ADD_ANCHOR_LINKS_URL . 'assets/css/add-anchor-links.css', array(), ADD_ANCHOR_LINKS_VERSION ); } } /** * Default options * @since 1.0.0 */ function add_anchor_links_options_defaults() { $default_options = array( 'own_css' => false, 'post_types' => false, ); $post_types = add_anchor_links_post_types(); foreach ( $post_types as $pt ) { $default_options[$pt] = false; } return $default_options; } /** * Get post types where the AAL is enabled * @since 1.0.0 */ function add_anchor_links_post_types( $active = false ) { $post_types = get_post_types( array( 'public' => true, ) ); if ( $active ) { global $add_anchor_links_options; $_post_types = $post_types; $post_types = array(); foreach( $_post_types as $pt ) { if ( isset($add_anchor_links_options[$pt] ) && $add_anchor_links_options[$pt] ) { $post_types[] = $pt; } } } return $post_types; } /** * Runs only when the plugin is activated. * @since 1.0.1 */ function add_anchor_links_activation_hook() { /* Create transient data */ set_transient( 'aal-admin-notice-activation', true, 5 ); } register_activation_hook( __FILE__, 'add_anchor_links_activation_hook' ); /** * Admin Notice on Activation. * @since 1.0.1 */ function add_anchor_links_admin_notice_activation(){ /* Check transient, if available display notice */ if( get_transient( 'aal-admin-notice-activation' ) ){ ?>
', '', '' ); ?>