Created
March 8, 2013 13:46
-
-
Save tareq1988/5116537 to your computer and use it in GitHub Desktop.
A simple theme options page created with WordPress Settings API PHP class https://github.com/tareq1988/wordpress-settings-api-class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once dirname( __FILE__ ) . '/class.settings-api.php'; | |
/** | |
* Theme Admin panel for Tareq's Planet | |
* | |
* @author Tareq Hasan | |
*/ | |
class Tareqs_Planet_Admin { | |
private $settings_api; | |
function __construct() { | |
$this->settings_api = new WeDevs_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_theme_page( 'Theme Options', 'Theme Options', 'delete_posts', 'theme-option', array( $this, 'plugin_page' ) ); | |
} | |
function get_settings_sections() { | |
$sections = array( | |
array( | |
'id' => 'tp_settings', | |
'title' => __( 'Basic Settings', 'wedevs' ) | |
), | |
array( | |
'id' => 'tp_og', | |
'title' => __( 'Open Graph', 'wedevs' ) | |
), | |
); | |
return $sections; | |
} | |
/** | |
* Returns all the settings fields | |
* | |
* @return array settings fields | |
*/ | |
function get_settings_fields() { | |
$settings_fields = array( | |
'tp_settings' => array( | |
array( | |
'name' => 'projects_desc', | |
'label' => __( 'Project Details', 'wedevs' ), | |
'type' => 'textarea' | |
), | |
array( | |
'name' => 'footer_js', | |
'label' => __( 'Footer JS', 'wedevs' ), | |
'type' => 'textarea' | |
), | |
array( | |
'name' => 'footer_css', | |
'label' => __( 'Footer CSS', 'wedevs' ), | |
'type' => 'textarea' | |
) | |
), | |
'tp_og' => array( | |
array( | |
'label' => __( 'Admin Account ID', 'wedevs' ), | |
'desc' => __( 'Must enter one, if you want to receive insights (analytics) about the Like Buttons. You can find it by going to the URL like this: http://graph.facebook.com/tareq1988', 'wedevs' ), | |
'name' => 'fb_page_admin', | |
'type' => 'text' | |
), | |
array( | |
'label' => __( 'Default Image', 'wedevs' ), | |
'desc' => __( 'Enter the URL for your default image. This will show if your post does not have a thumbnail.', 'wedevs' ), | |
'name' => 'fb_default_image', | |
'type' => 'text' | |
) | |
) | |
); | |
return $settings_fields; | |
} | |
function plugin_page() { | |
echo '<div class="wrap">'; | |
settings_errors(); | |
$this->settings_api->show_navigation(); | |
$this->settings_api->show_forms(); | |
echo '</div>'; | |
} | |
} | |
$settings = new Tareqs_Planet_Admin(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment