Overview

Namespaces

  • None
  • PHP

Classes

  • Sidecar
  • Sidecar_Admin_Page
  • Sidecar_Admin_Tab
  • Sidecar_Field
  • Sidecar_Form
  • Sidecar_Form_Settings
  • Sidecar_Plugin_Base
  • Sidecar_Plugin_Settings
  • Sidecar_Settings_Base
  • Sidecar_Shortcode
  • Sidecar_Singleton_Base

Functions

  • body
  • format_gmt_string
  • headers
  • output_css
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
  1: <?php
  2: /**
  3:  *
  4:  */
  5: class Sidecar_Admin_Tab {
  6:   /**
  7:    * @var Sidecar_Plugin_Base
  8:    */
  9:   var $plugin;
 10:   /**
 11:    * @var string
 12:    */
 13:   var $tab_slug;
 14:   /**
 15:    * @var string
 16:    */
 17:   var $tab_text;
 18:   /**
 19:    * @var bool|string
 20:    */
 21:   var $page_title = false;
 22:   /**
 23:    * @var bool|callable
 24:    */
 25:   var $tab_handler = false;
 26:   /**
 27:    * @var bool|string
 28:    */
 29:   var $before_page_title = false;
 30:   /**
 31:    * @var bool|string
 32:    */
 33:   var $before_content = false;
 34:   /**
 35:    * @var bool|string
 36:    */
 37:   var $after_content = false;
 38:   /**
 39:    * @var string|Sidecar_Form
 40:    */
 41:   var $forms = array();
 42: 
 43:   /**
 44:    * @param string $tab_slug
 45:    * @param string $tab_text
 46:    * @param array $args
 47:    */
 48:   function __construct( $tab_slug, $tab_text, $args = array() ) {
 49:     $this->tab_slug = $tab_slug;
 50:     $this->tab_text = $tab_text;
 51: 
 52:     /**
 53:      * Copy properties in from $args, if they exist.
 54:      */
 55:     foreach( $args as $property => $value ) {
 56:       if ( property_exists( $this, $property ) ) {
 57:         $this->$property = $value;
 58:       } else if ( property_exists( $this, $property = "tab_{$property}" ) ) {
 59:         $this->$property = $value;
 60:       }
 61:     }
 62: 
 63:     if ( empty( $this->page_title ) && false !== $this->page_title )
 64:       $this->page_title = $tab_text;
 65: 
 66:     if ( ! $this->forms && isset( $args['form'] ) ) {
 67:       /**
 68:        * Is 'form' passed in (singluar) grab it, otherwise grab the tab slug.
 69:        * Later convert the current tab's form to an object.
 70:        * Note: If form is passed as only 'true' then get the tab slug,
 71:        */
 72: 
 73:       if ( true === $args['form'] )
 74:         $args['form'] = $tab_slug;
 75: 
 76:       $this->forms = array( $args['form'] );
 77:      // $this->forms = array( isset( $args['form'] ) ? $args['form'] : $tab_slug );
 78:     }
 79:   }
 80:   /**
 81:    * @return bool
 82:    */
 83:   function has_forms() {
 84:     return is_array( $this->forms );
 85:   }
 86: 
 87:   /**
 88:    * Determines if this tab has one of more form(s) that require an API.
 89:    *
 90:    * @return bool
 91:    */
 92:   function requires_api() {
 93:     $requires_api = false;
 94:     /**
 95:      * @var string|array|Sidecar_Form $form
 96:      */
 97:     foreach( $this->forms as $index => $form ) {
 98:       if ( ! is_object( $form ) )
 99:         $form = $this->plugin->get_form( $form );
100:       if ( $form->requires_api ) {
101:         $requires_api = true;
102:         break;
103:       }
104:     }
105:     return $requires_api;
106:   }
107: 
108: }
109: 
API documentation generated by ApiGen 2.8.0