settings_api = new About_Author_Box_Settings_API; // add the admin page add_action( 'admin_menu', array( $this, 'add_admin_page' ) ); // pass the section and settings data to the API class add_action( 'admin_init', array( $this, 'admin_init' ), 9 ); // custom welcome page add_action( 'about_author_box_settings_api_display_about_author_box_general_settings_section', array( $this, 'display_welcome_page' ) ); // plugin action links add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 ); } /** * Pass the sectiona and settings data to the API class * * @since 1.0.0 */ function admin_init() { $this->settings_api->set_sections( $this->get_sections() ); $this->settings_api->set_fields( $this->get_fields() ); } /** * Define sections * * @since 1.0.0 */ public static function get_sections() { // array of sections $sections = array( array( 'id' => 'about_author_box_general_settings_section', 'title' => esc_html__( 'Welcome', 'about-author-box' ), 'parent' => 'about_author_box', 'page' => 'about_author_box_general_settings_page', 'option' => 'about_author_box_general_settings', 'display' => false, ), array( 'id' => 'about_author_box_before_content_settings_section', 'title' => esc_html__( 'Before Content', 'about-author-box' ), 'parent' => 'about_author_box', 'page' => 'about_author_box_before_content_settings_page', 'option' => 'about_author_box_before_content_settings', ), array( 'id' => 'about_author_box_after_content_settings_section', 'title' => esc_html__( 'After Content', 'about-author-box' ), 'parent' => 'about_author_box', 'page' => 'about_author_box_after_content_settings_page', 'option' => 'about_author_box_after_content_settings', ), array( 'id' => 'about_author_box_shortcode_settings_section', 'title' => esc_html__( 'Shortcode', 'about-author-box' ), 'parent' => 'about_author_box', 'page' => 'about_author_box_shortcode_settings_page', 'option' => 'about_author_box_shortcode_settings', ), ); // pass it back return $sections; } /** * Define fields * * @since 1.0.0 */ public static function get_fields() { // start with an empty array which we populate below $fields = array(); // general settings $fields['about_author_box_general_settings_section'] = array( ); // before content settings $fields['about_author_box_before_content_settings_section'] = array( array( 'id' => 'enabled', 'title' => esc_html__( 'Enable/Disable', 'about-author-box' ), 'descr' => esc_html__( 'Should the author box show before the content.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Enabled', 'about-author-box' ), '0' => esc_html__( 'Disabled', 'about-author-box' ), ), 'default' => '0', ), array( 'id' => 'avatar', 'title' => esc_html__( 'Avatar', 'about-author-box' ), 'descr' => esc_html__( 'Should the user avatar show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'avatar_size', 'title' => esc_html__( 'Avatar Size', 'about-author-box' ), 'descr' => esc_html__( 'Which size should the avatar be ( in pixels ).', 'about-author-box' ), 'type' => 'number', 'default' => '25', ), array( 'id' => 'avatar_style', 'title' => esc_html__( 'Avatar Style', 'about-author-box' ), 'descr' => esc_html__( 'What style should the avatar be.', 'about-author-box' ), 'type' => 'select', 'choices' => array( 'square' => esc_html__( 'Square', 'about-author-box' ), 'rounded' => esc_html__( 'Rounded', 'about-author-box' ), 'circle' => esc_html__( 'Circle', 'about-author-box' ), ), 'default' => 'circle', ), array( 'id' => 'avatar_position', 'title' => esc_html__( 'Avatar Position', 'about-author-box' ), 'descr' => esc_html__( 'Where should the avatar be positioned.', 'about-author-box' ), 'type' => 'select', 'page' => 'about-author-after-post-content', 'section' => 'about_author_box_about-author-after-post-content_section', 'choices' => array( 'left' => esc_html__( 'Left', 'about-author-box' ), 'right' => esc_html__( 'Right', 'about-author-box' ), ), 'default' => 'left', ), array( 'id' => 'name', 'title' => esc_html__( 'Name', 'about-author-box' ), 'descr' => esc_html__( 'Should the name show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'date', 'title' => esc_html__( 'Date', 'about-author-box' ), 'descr' => esc_html__( 'Should the post publish date show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'bio', 'title' => esc_html__( 'Bio', 'about-author-box' ), 'descr' => esc_html__( 'Should the user bio (description) show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '0', ), array( 'id' => 'social', 'title' => esc_html__( 'Social Links', 'about-author-box' ), 'descr' => esc_html__( 'Should the social links show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '0', ), array( 'id' => 'style_border', 'title' => esc_html__( 'Style - Border', 'about-author-box' ), 'descr' => esc_html__( 'Should the author box be wrapped in a border.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( 'none' => esc_html__( 'None', 'about-author-box' ), 'full' => esc_html__( 'Full', 'about-author-box' ), 'horizontal' => esc_html__( 'Horizontal', 'about-author-box' ), ), 'default' => 'none', ), ); // after content settings $fields['about_author_box_after_content_settings_section'] = array( array( 'id' => 'enabled', 'title' => esc_html__( 'Enable/Disable', 'about-author-box' ), 'descr' => esc_html__( 'Should the author box show after the content.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Enabled', 'about-author-box' ), '0' => esc_html__( 'Disabled', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'avatar', 'title' => esc_html__( 'Avatar', 'about-author-box' ), 'descr' => esc_html__( 'Should the user avatar show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'avatar_size', 'title' => esc_html__( 'Avatar Size', 'about-author-box' ), 'descr' => esc_html__( 'Which size should the avatar be ( in pixels ).', 'about-author-box' ), 'type' => 'number', 'default' => '120', ), array( 'id' => 'avatar_style', 'title' => esc_html__( 'Avatar Style', 'about-author-box' ), 'descr' => esc_html__( 'What style should the avatar be.', 'about-author-box' ), 'type' => 'select', 'choices' => array( 'square' => esc_html__( 'Square', 'about-author-box' ), 'rounded' => esc_html__( 'Rounded', 'about-author-box' ), 'circle' => esc_html__( 'Circle', 'about-author-box' ), ), 'default' => 'square', ), array( 'id' => 'avatar_position', 'title' => esc_html__( 'Avatar Position', 'about-author-box' ), 'descr' => esc_html__( 'Where should the avatar be positioned.', 'about-author-box' ), 'type' => 'select', 'page' => 'about-author-after-post-content', 'section' => 'about_author_box_about-author-after-post-content_section', 'choices' => array( 'left' => esc_html__( 'Left', 'about-author-box' ), 'right' => esc_html__( 'Right', 'about-author-box' ), ), 'default' => 'left', ), array( 'id' => 'name', 'title' => esc_html__( 'Name', 'about-author-box' ), 'descr' => esc_html__( 'Should the name show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'date', 'title' => esc_html__( 'Date', 'about-author-box' ), 'descr' => esc_html__( 'Should the post publish date show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'bio', 'title' => esc_html__( 'Bio', 'about-author-box' ), 'descr' => esc_html__( 'Should the user bio (description) show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'social', 'title' => esc_html__( 'Social Links', 'about-author-box' ), 'descr' => esc_html__( 'Should the social links show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'style_border', 'title' => esc_html__( 'Style - Border', 'about-author-box' ), 'descr' => esc_html__( 'Should the author box be wrapped in a border.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( 'none' => esc_html__( 'None', 'about-author-box' ), 'full' => esc_html__( 'Full', 'about-author-box' ), 'horizontal' => esc_html__( 'Horizontal', 'about-author-box' ), ), 'default' => 'none', ), ); // after content settings $fields['about_author_box_shortcode_settings_section'] = array( array( 'id' => 'enabled', 'title' => esc_html__( 'Enable/Disable', 'about-author-box' ), 'descr' => esc_html__( 'Should the author box show when the shortcode is called.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Enabled', 'about-author-box' ), '0' => esc_html__( 'Disabled', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'avatar', 'title' => esc_html__( 'Avatar', 'about-author-box' ), 'descr' => esc_html__( 'Should the user avatar show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'avatar_size', 'title' => esc_html__( 'Avatar Size', 'about-author-box' ), 'descr' => esc_html__( 'Which size should the avatar be ( in pixels ).', 'about-author-box' ), 'type' => 'number', 'default' => '120', ), array( 'id' => 'avatar_style', 'title' => esc_html__( 'Avatar Style', 'about-author-box' ), 'descr' => esc_html__( 'What style should the avatar be.', 'about-author-box' ), 'type' => 'select', 'choices' => array( 'square' => esc_html__( 'Square', 'about-author-box' ), 'rounded' => esc_html__( 'Rounded', 'about-author-box' ), 'circle' => esc_html__( 'Circle', 'about-author-box' ), ), 'default' => 'square', ), array( 'id' => 'avatar_position', 'title' => esc_html__( 'Avatar Position', 'about-author-box' ), 'descr' => esc_html__( 'Where should the avatar be positioned.', 'about-author-box' ), 'type' => 'select', 'page' => 'about-author-after-post-content', 'section' => 'about_author_box_about-author-after-post-content_section', 'choices' => array( 'left' => esc_html__( 'Left', 'about-author-box' ), 'right' => esc_html__( 'Right', 'about-author-box' ), ), 'default' => 'left', ), array( 'id' => 'name', 'title' => esc_html__( 'Name', 'about-author-box' ), 'descr' => esc_html__( 'Should the name show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'date', 'title' => esc_html__( 'Date', 'about-author-box' ), 'descr' => esc_html__( 'Should the post publish date show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'bio', 'title' => esc_html__( 'Bio', 'about-author-box' ), 'descr' => esc_html__( 'Should the user bio (description) show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'social', 'title' => esc_html__( 'Social Links', 'about-author-box' ), 'descr' => esc_html__( 'Should the social links show.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( '1' => esc_html__( 'Show', 'about-author-box' ), '0' => esc_html__( 'Hide', 'about-author-box' ), ), 'default' => '1', ), array( 'id' => 'style_border', 'title' => esc_html__( 'Style - Border', 'about-author-box' ), 'descr' => esc_html__( 'Should the author box be wrapped in a border.', 'about-author-box' ), 'type' => 'radio', 'choices' => array( 'none' => esc_html__( 'None', 'about-author-box' ), 'full' => esc_html__( 'Full', 'about-author-box' ), 'horizontal' => esc_html__( 'Horizontal', 'about-author-box' ), ), 'default' => 'none', ), ); // pass it back return $fields; } /** * Add the admin page * * @since 1.0.0 */ function add_admin_page() { $parent = 'options-general.php'; $page_title = esc_html__( 'Author Box', 'about-author-box' ); $menu_title = esc_html__( 'Author Box', 'about-author-box' ); $capability = 'manage_options'; $slug = 'about_author_box'; $function = array( $this, 'display_admin_page' ); add_submenu_page( $parent, $page_title, $menu_title, $capability, $slug, $function ); } /** * Display the admin page * * @since 1.0.0 */ function display_admin_page() { ?>