settings_api = new AmityTheme_Settings_API; add_action( 'admin_init', array($this, 'admin_init') ); add_action( 'admin_menu', array($this, 'admin_menu') ); } function admin_init() { //set the settings $this->settings_api->set_sections( $this->get_settings_sections() ); $this->settings_api->set_fields( $this->get_settings_fields() ); //initialize settings $this->settings_api->admin_init(); } function admin_menu() { add_options_page( 'ARP Options', 'ARP Options', 'delete_posts', 'arp-related-posts', array($this, 'arp_plugin_page') ); // Returning true. return true; } function get_settings_sections() { $sections = array( array( 'id' => 'arp_basics', 'title' => __( 'Basic Options', 'arp' ) ), array( 'id' => 'arp_styles', 'title' => __('Style Options', 'arp') ) ); return $sections; } /** * Returns all the settings fields * * @return array settings fields */ function get_settings_fields() { $settings_fields = array( 'arp_basics' => array( array( 'name' => 'arp-main-title', 'label' => __( 'Type in the main title text. ', 'arp' ), 'type' => 'text', 'default' => 'Amity Related Posts' ), array( 'name' => 'arp-no-posts', 'label' => __( 'Number Of Posts Display', 'arp' ), 'desc' => __( 'How many post you want to display. Recommended 3 or 6', 'arp' ), 'type' => 'number', 'default' => '6' ), array( 'name' => 'arp-grid-list', 'label' => __('Post Display Style', 'arp'), 'desc' => __('Grid Style or List Style', 'arp'), 'type' => 'radio', 'default' => 'grid', 'options' => array( 'grid' => 'Grid', 'list' => 'List' ) ), array( 'name' => 'arp-grid-styles', 'label' => __('Types of Grid Style', 'arp'), 'desc' => __('If you select Grid Style', 'arp'), 'type' => 'select', 'default' => '33.3333%', 'options' => array( '50%' => '2 column', '33.3333%' => '3 column', '25%' => '4 column' ) ), ), 'arp_styles' => array( array( 'name' => 'arp-main-title-font-size', 'label' => __('Main Title Font Size', 'arp'), 'desc' => __('Recommended Font Size: 24px;', 'arp'), 'type' => 'number', 'default' => '24' ), array( 'name' => 'arp-main-title-font-color', 'label' => __('Main Title Color', 'arp'), 'desc' => __('Select a color for main title', 'arp'), 'type' => 'color', 'default' => '' ), array( 'name' => 'arp-post-title-font-size', 'label' => __('Post Title Font Size', 'arp'), 'desc' => __('Recommended Font Size: 16px;', 'arp'), 'type' => 'number', 'default' => '16' ), array( 'name' => 'arp-post-title-font-color', 'label' => __('Post Title Color', 'arp'), 'desc' => __('Select a color for post title', 'arp'), 'type' => 'color', 'default' => '' ) ) ); return $settings_fields; } function arp_plugin_page() { echo '
'; $this->settings_api->show_navigation(); $this->settings_api->show_forms(); echo '
'; } /** * Get all the pages * * @return array page names with key value pairs */ function get_pages() { $pages = get_pages(); $pages_options = array(); if ( $pages ) { foreach ($pages as $page) { $pages_options[$page->ID] = $page->post_title; } } return $pages_options; } } endif; $settings = new ARP_Settings_API_Related_Post();