Beispiel #1
0
 /**
  * Register autoloader.
  *
  * @return  void
  */
 function autoload()
 {
     IG_Loader::register(IG_PB_PATH . 'core', 'IG_Pb_');
     IG_Loader::register(IG_PB_PATH . 'core/gadget', 'IG_Gadget_');
     // Allow autoload registration from outside
     do_action('ig_pb_autoload');
 }
Beispiel #2
0
 /**
  * Render addons installation and management screen.
  *
  * @param   string  $plugin_file  Either absolute path to plugin main file or plugin's identified name defined in InnoGears server.
  *
  * @return  void
  */
 public static function init($plugin_file)
 {
     // Get template path
     if ($tmpl = IG_Loader::get_path('product/tmpl/addons.php')) {
         // Get product information
         $plugin = self::get($plugin_file);
         if (!$plugin) {
             die(__('Cannot get addons information for current product.', IG_LIBRARY_TEXTDOMAIN));
         }
         // Check if user has customer account saved
         $customer_account = get_option('ig_customer_account', null);
         $has_customer_account = is_array($customer_account) && !@empty($customer_account['username']) && !@empty($customer_account['password']);
         // Load template
         include_once $tmpl;
     }
 }
Beispiel #3
0
		<div id="ig_<?php 
    esc_attr_e($aid);
    ?>
" class="panel-collapse collapse <?php 
    if ($first) {
        echo 'in';
    }
    ?>
">
			<div class="panel-body">
				<?php 
    if (isset($accordion['fields'])) {
        $this->current_fields = $accordion['fields'];
        // Load fields template
        include IG_Loader::get_path('form/tmpl/fields.php');
    }
    if (isset($accordion['fieldsets'])) {
        $this->current_fieldsets = $accordion['fieldsets'];
        // Load fieldsets template
        include IG_Loader::get_path('form/tmpl/fieldsets.php');
    }
    ?>
			</div>
		</div>
	</div>
<?php 
    $first = false;
}
?>
</div>
Beispiel #4
0
 /**
  * Render the output.
  *
  * @param   string  $action  Gadget action to execute.
  *
  * @return  void
  */
 protected function render($action = 'default')
 {
     // Clean all buffered output
     while (ob_get_level()) {
         ob_end_clean();
     }
     // Get response
     $response = $this->get_response();
     // Tell browser that JSON string is returned
     @header('Content-Type: application/json');
     // Check if template file exists for requested gadget action
     $file = IG_Loader::get_path("gadget/tmpl/{$this->gadget}/{$action}.php");
     if ('success' == $response['status'] && !empty($file)) {
         // Start output buffering
         ob_start();
         // Extract response array to variables: $status and $data
         extract($response);
         // Load template file to render output
         include_once $file;
         // Get final response
         $response['data'] = ob_get_clean();
         if (empty($response['data']) && $response != $this->get_response()) {
             $response = $this->get_response();
         }
     }
     // Print the JSON encoded response then xxit immediately to prevent WordPress from processing further
     exit(json_encode($response));
 }
Beispiel #5
0
 /**
  * Register Path to extended Parameter type
  *
  * @param string $path
  */
 public function register_extended_parameter_path($path)
 {
     IG_Loader::register($path, 'IG_Pb_Helper_Html_');
 }
Beispiel #6
0
 /**
  * Search a file in registered paths.
  *
  * @param   string  $file  Relative file path to search for.
  *
  * @return  string
  */
 public static function get_path($file)
 {
     // Generate alternative file name
     $slave = str_replace('_', '-', $file);
     // Filter paths to search for file
     self::$paths = apply_filters('ig_loader_get_path', self::$paths);
     foreach (array_reverse(self::$paths) as $base => $prefixes) {
         if (@is_file($base . '/' . $slave)) {
             return $base . '/' . $slave;
         } elseif (@is_file($base . '/' . $file)) {
             return $base . '/' . $file;
         }
     }
     return null;
 }
Beispiel #7
0
    }
    ?>
" id="ig-form-tab-<?php 
    esc_attr_e($tid);
    ?>
">
			<?php 
    if (isset($tab['fields'])) {
        $this->current_fields = $tab['fields'];
        // Load fields template
        include IG_Loader::get_path('form/tmpl/fields.php');
    }
    if (isset($tab['fieldsets'])) {
        $this->current_fieldsets = $tab['fieldsets'];
        // Load fieldsets template
        include IG_Loader::get_path('form/tmpl/fieldsets.php');
    }
    if (isset($tab['accordion'])) {
        $this->current_accordion = $tab['accordion'];
        // Load accordion template
        include IG_Loader::get_path('form/tmpl/accordion.php');
    }
    ?>
		</div>
		<?php 
    $first = false;
}
?>
	</div>
</div>
Beispiel #8
0
 /**
  * Render form.
  *
  * @param   string   $alignment   Form alignment, either 'form-inline', 'form-horizontal' or leave empty for vertical alignment.
  * @param   array    $js_init     Print Javascript initialization for which: tabs, accordion, tips?
  * @param   string   $section_id  Which form section to render? Leave empty to render all sections by default.
  *
  * @return  void
  */
 public function render($alignment = null, $js_init = array('tips', 'accordions', 'tabs'), $section_id = '')
 {
     // Do 'ig_pre_render_form' action
     do_action('ig_pre_render_form', $this);
     // Render all form sections or a specified one?
     if (!empty($section_id) && array_key_exists($section_id, $this->fields)) {
         // Update Javascript initialization
         $js_init[] = 'ajax';
         // Backup current fields data
         $fields = $this->fields;
         // Remove data of unnecessary form section
         foreach (array_keys($this->fields) as $sid) {
             if ($section_id != $sid) {
                 unset($this->fields[$sid]['fields']);
                 unset($this->fields[$sid]['fieldsets']);
                 unset($this->fields[$sid]['accordion']);
                 unset($this->fields[$sid]['tabs']);
             }
         }
     }
     // Load assets
     IG_Init_Assets::load(array('ig-form-css', 'ig-form-js'));
     // Load form template
     if (!empty($alignment)) {
         $tpl = IG_Loader::get_path("form/tmpl/form-{$alignment}.php");
     }
     if (isset($tpl) && !empty($tpl)) {
         include $tpl;
     } else {
         include IG_Loader::get_path('form/tmpl/form.php');
     }
     // Render all form sections or a specified one?
     if (!empty($section_id) && array_key_exists($section_id, $this->fields)) {
         // Restore original fields data
         $this->fields = $fields;
     }
     // Do 'ig_post_render_form' action
     do_action('ig_post_render_form', $this);
 }
Beispiel #9
0
 /**
  * Render input field for user to interact with.
  *
  * @param   string  $tpl   Render field using this template.
  *
  * @return  string
  */
 protected function input($tpl = null)
 {
     // Prepare field template
     if (empty($tpl)) {
         $tpl = $this->type;
     }
     // Preset HTML code
     $html = '';
     // Backup current field attributes to allow recursive call
     $backup = $this->attributes;
     // Get path to template file
     $file = IG_Loader::get_path("form/field/tmpl/{$tpl}.php");
     if (empty($file)) {
         $file = IG_Loader::get_path('form/field/tmpl/text.php');
     }
     // Load field template
     ob_start();
     include $file;
     $html = ob_get_clean();
     // Restore field attributes
     $this->attributes = $backup;
     return $html;
 }
Beispiel #10
0
 /**
  * Autoload shortcodes & sub shortcodes
  *
  * @param string $path
  */
 public static function autoload_shortcodes($path)
 {
     $items = substr_count($path, '/item');
     $postfix = str_repeat('Item_', $items);
     // autoload shortcodes
     IG_Loader::register($path, 'IG_' . $postfix);
 }
Beispiel #11
0
        }
        ?>
" id="ig-form-section-<?php 
        esc_attr_e($sid);
        ?>
"<?php 
        if (isset($section['attributes'])) {
            echo ' ' . implode(' ', $section['attributes']);
        }
        ?>
>
<?php 
    }
    // Load section template
    if (!isset($_GET['ajax']) || !$_GET['ajax'] || empty($section_id) || $section_id == $sid) {
        include IG_Loader::get_path('form/tmpl/section.php');
    }
    if ($numSection > 1 && empty($section_id) || !isset($_GET['ajax']) || !$_GET['ajax']) {
        ?>
			</div>
<?php 
    }
    $first = false;
}
// Check if this is an Ajax request for specific form section
if (empty($section_id) || !isset($_GET['ajax']) || !$_GET['ajax']) {
    ?>
	</div>
<?php 
    if (!isset($this->action)) {
        ?>