plugin_slug; $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( __FILE__ ) ) . '/lang/' ); } /** * Load up custom css and js used in the admin panels for this plugin * * @since 1.0.0 */ public function archive_control_custom_admin_style_scripts() { wp_register_style( 'archive_control_admin_css', plugin_dir_url( __FILE__ ) . '/css/admin-style.css', false, self::VERSION ); wp_enqueue_style( 'archive_control_admin_css' ); wp_register_script( 'archive_control_admin_js', plugin_dir_url( __FILE__ ) . '/js/admin-scripts.js', 'jquery', self::VERSION, true ); $js_translations = array( 'media_upload_title_text' => __( 'Archive Featured Image', 'archive-control' ), 'media_upload_button_text' => __( 'Set featured image', 'archive-control' ) ); wp_localize_script( 'archive_control_admin_js', 'archive_control', $js_translations ); wp_enqueue_script( 'archive_control_admin_js' ); } /** * Used to insert a "Settings" link on the Plugin activation screen * * @since 1.0.0 * * @param array $links The array of existing links for the plugin */ public function archive_control_action_link( $links ) { $mylinks = array( '' . __('Settings', 'archive-control') . '', ); return array_merge( $links, $mylinks ); } /** * Activate the settings screens for the plugin * * @since 1.0.0 */ public function archive_control_menu() { add_options_page( __('Archive Control', 'archive-control'), __('Archive Control', 'archive-control'), 'manage_options', 'archive-control.php', array($this,'archive_control_options') ); $archive_control_options = get_option('archive_control_options'); if ($archive_control_options) { foreach($archive_control_options as $post_type => $options) { $title_val = isset($options['title']) ? $options['title'] : null; $image_val = isset($options['image']) ? $options['image'] : null; $before_val = isset($options['before']) ? $options['before'] : null; $after_val = isset($options['after']) ? $options['after'] : null; if ($title_val == 'custom' || $image_val == 'enabled' || $before_val == 'textarea' || $after_val == 'textarea') { if ($post_type == 'post') { $parent_slug = 'edit.php'; } else { $parent_slug = 'edit.php?post_type=' . $post_type; } add_submenu_page( $parent_slug, __('Edit Archive Page', 'archive-control'), __('Edit Archive Page', 'archive-control'), 'edit_posts', 'edit-archive-' . $post_type, array($this,'archive_control_edit_page_callback') ); } //has before or after value } } } /** * Register the necessary settings to store for plugin use. * * @since 1.0.0 */ public function archive_control_settings() { register_setting( 'archive-control-options-group', 'archive_control_options' ); $archive_control_options = get_option('archive_control_options'); if ($archive_control_options) { foreach($archive_control_options as $post_type => $options) { register_setting( 'archive-control-' . $post_type . '-group', 'archive_control_' . $post_type . '_title' ); register_setting( 'archive-control-' . $post_type . '-group', 'archive_control_' . $post_type . '_image' ); register_setting( 'archive-control-' . $post_type . '-group', 'archive_control_' . $post_type . '_before' ); register_setting( 'archive-control-' . $post_type . '-group', 'archive_control_' . $post_type . '_after' ); } } } /** * The variable settings screen that can be activated per custom post type * * @since 1.0.0 */ public function archive_control_edit_page_callback() { $screen = get_current_screen(); $current_post_type = $screen->post_type; $archive_control_options = get_option('archive_control_options'); $archive_control_cpt_title = get_option('archive_control_' . $current_post_type . '_title'); $archive_control_cpt_image = get_option('archive_control_' . $current_post_type . '_image'); $archive_control_cpt_before = get_option('archive_control_' . $current_post_type . '_before'); $archive_control_cpt_after = get_option('archive_control_' . $current_post_type . '_after'); if ($screen->post_type == '' && $screen->parent_file == 'edit.php') { $current_post_type = 'post'; } $current_post_type_object = get_post_type_object($current_post_type); $current_post_type_options = isset($archive_control_options[$current_post_type]) ? $archive_control_options[$current_post_type] : null; ?>