'5000', 'showcontrols' => 'true', 'showindicator' => 'true', 'customprev' => '', 'customnext' => '', 'orderby' => 'menu_order', 'order' => 'ASC', 'category' => '', 'before_title' => '
', 'after_caption' => '
', 'image_size' => 'full', 'id' => '', 'twbs' => '3', 'use_javascript_animation' => '1', ); add_option('twabc_settings', $defaults); } // Clean up on uninstall register_activation_hook(__FILE__, 'twabc_deactivate'); function twabc_deactivate(){ delete_option('twabc_settings'); } // Render the settings page class twabc_settings_page { // Holds the values to be used in the fields callbacks private $options; // Start up public function __construct() { add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); add_action( 'admin_init', array( $this, 'page_init' ) ); } // Add settings page public function add_plugin_page() { add_submenu_page('edit.php?post_type=twabc', 'Settings', 'Settings', 'manage_options', 'twabc-settings', array($this,'create_admin_page')); } // Options page callback public function create_admin_page() { // Set class property $this->options = get_option( 'twabc_settings' ); if(!$this->options){ twabc_set_options (); $this->options = get_option( 'twabc_settings' ); } ?>'.__('Basic setup of how each Carousel will function, what controls will show and which images will be displayed.', 'twabc-settings').'
'; } public function twabc_settings_setup() { echo ''.__('Change the setup of the carousel - how it functions.', 'twabc-settings').'
'; } public function twabc_settings_link_buttons_header() { echo ''.__('Options for using a link button instead of linking the image directly.', 'twabc-settings').'
'; } public function twabc_settings_markup_header() { echo ''.__('Customise which CSS classes and HTML tags the Carousel uses.', 'twabc-settings').'
'; } // Callback functions - print the form inputs // Carousel behaviour public function interval_callback() { printf('', isset( $this->options['interval'] ) ? esc_attr( $this->options['interval']) : ''); echo ''.__('How long each image shows for before it slides. Set to 0 to disable animation.', 'twabc-settings').'
'; } public function showcaption_callback() { if(isset( $this->options['showcaption'] ) && $this->options['showcaption'] == 'false'){ $twabc_showcaption_t = ''; $twabc_showcaption_f = ' selected="selected"'; } else { $twabc_showcaption_t = ' selected="selected"'; $twabc_showcaption_f = ''; } echo ''; } public function showcontrols_callback() { if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'false'){ $twabc_showcontrols_t = ''; $twabc_showcontrols_f = ' selected="selected"'; $twabc_showcontrols_c = ''; } else if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'true'){ $twabc_showcontrols_t = ' selected="selected"'; $twabc_showcontrols_f = ''; $twabc_showcontrols_c = ''; } else if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'custom'){ $twabc_showcontrols_t = ''; $twabc_showcontrols_f = ''; $twabc_showcontrols_c = ' selected="selected"'; } echo ''; } public function showindicator_callback() { if(isset( $this->options['showindicator'] ) && $this->options['showindicator'] == 'false'){ $twabc_showcontrols_t = ''; $twabc_showcontrols_f = ' selected="selected"'; $twabc_showcontrols_c = ''; } else if(isset( $this->options['showindicator'] ) && $this->options['showindicator'] == 'true'){ $twabc_showcontrols_t = ' selected="selected"'; $twabc_showcontrols_f = ''; $twabc_showcontrols_c = ''; } else if(isset( $this->options['showindicator'] ) && $this->options['showindicator'] == 'custom'){ $twabc_showcontrols_t = ''; $twabc_showcontrols_f = ''; $twabc_showcontrols_c = ' selected="selected"'; } echo ''; } public function orderby_callback() { $orderby_options = array ( 'menu_order' => __('Menu order, as set in Carousel overview page', 'twabc-settings'), 'date' => __('Date slide was published', 'twabc-settings'), 'rand' => __('Random ordering', 'twabc-settings'), 'title' => __('Slide title', 'twabc-settings') ); echo ''; } public function order_callback() { if(isset( $this->options['order'] ) && $this->options['order'] == 'DESC'){ $twabc_showcontrols_a = ''; $twabc_showcontrols_d = ' selected="selected"'; } else { $twabc_showcontrols_a = ' selected="selected"'; $twabc_showcontrols_d = ''; } echo ''; } public function category_callback() { $cats = get_terms('carousel_category'); echo ''; } // Setup Section public function twbs_callback() { if(isset( $this->options['twbs'] ) && $this->options['twbs'] == '3'){ $twabc_twbs3 = ' selected="selected"'; $twabc_twbs4 = ''; } else { $$twabc_twbs3 = ' selected="selected"'; $twabc_twbs4 = ''; } echo ''; echo ''.__("Set according to which version of Bootstrap you're using.", 'twabc-settings').'
'; } public function image_size_callback() { $image_sizes = get_intermediate_image_sizes(); echo ''; echo ''.__("If your carousels are small, you can a smaller image size to increase page load times.", 'twabc-settings').'
'; } public function use_javascript_animation_callback() { echo ''; echo ''.__("The Bootstrap Carousel is designed to work usign data-attributes. Sometimes the animation doesn't work correctly with this, so the default is to include a small portion of Javascript to fire the carousel. You can choose not to include this here.", 'twabc-settings').'
'; } } if( is_admin() ){ $twabc_settings_page = new twabc_settings_page(); } // Add settings link on plugin page function twabc_settings_link ($links) { $settings_link = ''.__('Settings', 'twabc-settings').''; array_unshift($links, $settings_link); return $links; } $twabc_plugin = plugin_basename(__FILE__); add_filter("plugin_action_links_$twabc_plugin", 'twabc_settings_link' );