/**
 *
 * Function used to load updates page view
 *
 * @return null
 * 
 **/
function gavern_updates_options()
{
    // check permissions
    if (!current_user_can('manage_options')) {
        wp_die(__('You don\'t have sufficient permissions to access this page!', GKTPLNAME));
    }
    include_once gavern_file('gavern/layouts/updates.php');
}
/**
 *
 * Function to create template options page
 *
 * @return null
 *
 **/
function gavern_template_options()
{
    // getting access to the template global object.
    global $tpl;
    // check permissions
    if (!current_user_can('manage_options')) {
        wp_die(__('You don\'t have sufficient permissions to access this page!', GKTPLNAME));
    }
    include_once gavern_file('gavern/layouts/template.php');
}
/**
 *
 * Function used to load specific layout parts
 *
 * @return null
 *
 **/
function gk_load($part_name, $assets = null, $args = null)
{
    if ($assets !== null) {
        foreach ($assets as $key => $value) {
            if ($key == 'css') {
                wp_enqueue_style('gavern-gallery-template', $value, array('gavern-stuff'));
            } elseif ($key == 'js') {
                wp_enqueue_script('gavern-gallery-template', $value, array('jquery'));
            }
        }
    }
    include gavern_file('layouts/' . $part_name . '.php');
    if ($part_name = 'header') {
        do_action('get_header', $part_name);
    }
}
 /**
  *
  * Function used to parse the JSON data
  * 
  * @retunr HTML output
  *
  **/
 private function output()
 {
     // prepare empty string for the output
     $prepared_data = '';
     $standard_fields = array('Text', 'RawText', 'Select', 'Switcher', 'Textarea', 'Media', 'WidthHeight', 'TextBlock');
     // parse groups
     foreach ($this->loaded_data as $group) {
         //
         $prepared_data .= '<fieldset><legend>' . $group->groupname . '</legend>';
         $prepared_data .= '<p><small>' . $group->groupdesc . '</small></p>';
         foreach ($group->fields as $field) {
             if (in_array($field->type, $standard_fields)) {
                 $className = 'GKFormInput' . $field->type;
                 $output = new $className($this->tpl, isset($field->name) ? $field->name : null, isset($field->label) ? $field->label : null, isset($field->tooltip) ? $field->tooltip : null, isset($field->default) ? $field->default : null, isset($field->class) ? $field->class : null, isset($field->format) ? $field->format : null, isset($field->required) ? $field->required : null, isset($field->visibility) ? $field->visibility : null, isset($field->other) ? $field->other : null);
                 $prepared_data .= $output->output();
             } else {
                 // load field config
                 $file_config = $this->tpl->get_json('form_elements/' . $field->type, 'config', false);
                 // check if the file is correct
                 if (is_array($file_config) && count($file_config) > 0 || is_object($file_config)) {
                     // load these files only once time
                     if (!class_exists($file_config->class)) {
                         // load the main PHP class
                         include_once gavern_file('gavern/form_elements/') . $field->type . '/' . $file_config->php;
                     }
                     // create the object
                     if (class_exists($file_config->class)) {
                         $className = $file_config->class;
                         $output = new $className($this->tpl, isset($field->name) ? $field->name : null, isset($field->label) ? $field->label : null, isset($field->tooltip) ? $field->tooltip : null, isset($field->default) ? $field->default : null, isset($field->class) ? $field->class : null, isset($field->format) ? $field->format : null, isset($field->required) ? $field->required : null, isset($field->visibility) ? $field->visibility : null, isset($field->other) ? $field->other : null);
                         $prepared_data .= $output->output();
                     }
                 } else {
                     array_push($this->tpl->problems, 'JSON ERROR: config file for the element ' . $field->type . ' doesn\'t exist or is incorrect');
                 }
             }
         }
         $prepared_data .= '</fieldset>';
     }
     // return the created output
     return $prepared_data;
 }
示例#5
0
 /**
  *
  * Function to load specific JSON file
  * 
  * @param dir - the directory with JSON files
  * @param filename - name of the file to load - without ".json" extension
  * @param lang - if the directory supports multilanguage support
  *
  * @return JSON object from the loaded file
  * 
  **/
 public function get_json($dir, $filename, $lang = true)
 {
     // lang dir
     $lang = $lang ? $this->language . '/' : '';
     if (defined('ICL_SITEPRESS_VERSION')) {
         $lang = apply_filters('gavern-get-json', $dir, $lang);
     }
     $path = gavern_file('gavern/' . $dir . '/' . $lang . $filename . '.json');
     // check if the specified file exists
     if (file_exists($path)) {
         // decode data from the JSON file
         $json_data = json_decode(file_get_contents($path));
         // check for the older PHP versions
         if (function_exists('json_last_error')) {
             // get the errors
             switch (json_last_error()) {
                 case JSON_ERROR_DEPTH:
                     array_push($this->problems, 'JSON ERROR: Maximum stack depth exceeded in ' . $path);
                     return array();
                     break;
                 case JSON_ERROR_CTRL_CHAR:
                     array_push($this->problems, 'JSON ERROR: Unexpected control character found in ' . $path);
                     return array();
                     break;
                 case JSON_ERROR_SYNTAX:
                     array_push($this->problems, 'JSON ERROR: Syntax error, malformed JSON in ' . $path);
                     return array();
                     break;
                 case JSON_ERROR_NONE:
                     // No errors
                     return json_decode(file_get_contents($path));
                     break;
             }
         } else {
             return json_decode(file_get_contents($path));
         }
     } else {
         // if the file doesn't exist - push the error
         array_push($this->problems, 'JSON ERROR: file ' . $path . ' doesn\'t exist');
         return array();
     }
 }
require_once gavern_file('gavern/widgets.comments.php');
require_once gavern_file('gavern/widgets.nsp.php');
require_once gavern_file('gavern/widgets.social.php');
require_once gavern_file('gavern/widgets.tabs.php');
// Including file with template admin features
require_once gavern_file('gavern/helpers/helpers.features.php');
// Including file with template shortcodes
require_once gavern_file('gavern/helpers/helpers.shortcodes.php');
// Including file with template layout functions
require_once gavern_file('gavern/helpers/helpers.layout.php');
// Including file with template layout functions - connected with template fragments
require_once gavern_file('gavern/helpers/helpers.layout.fragments.php');
// Including file with template branding functions
require_once gavern_file('gavern/helpers/helpers.branding.php');
// Including file with template customize functions
require_once gavern_file('gavern/helpers/helpers.customizer.php');
// initialize the framework
$tpl->init();
// add theme setup function
add_action('after_setup_theme', 'gavern_theme_setup');
// Theme setup function
function gavern_theme_setup()
{
    // access to the global template object
    global $tpl;
    // variable used for redirects
    global $pagenow;
    // check if the themes.php address with goto variable has been used
    if ($pagenow == 'themes.php' && !empty($_GET['goto'])) {
        /**
         *
示例#7
0
// disable direct access to the file
defined('GAVERN_WP') or die('Access denied');
/**
 *
 * GavernWP admin panel & page features
 *
 * Functions used to create GavernWP-specific functions 
 *
 **/
/**
*
* Code to inlcude necessary plugins
*
**/
// include TGM Plugin Activation class
require_once gavern_file('gavern/classes/class-tgm-plugin-activation.php');
/**
 * Register the required plugins for this theme.
 *
 * The variable passed to tgmpa_register_plugins() should be an array of plugin
 * arrays.
 *
 * This function is hooked into tgmpa_init, which is fired within the
 * TGM_Plugin_Activation class constructor.
 */
function gavern_register_required_plugins()
{
    /**
     * Array of plugin arrays. Required keys are name and slug.
     * 
     */
示例#8
0
<?php

// disable direct access to the file
defined('GAVERN_WP') or die('Access denied');
// access to the template object
global $gk_tpl;
// load the form parser
include_once gavern_file('gavern/form.parser.php');
// create a new instance of the form parser
$parser = new GavernWPFormParser($gk_tpl);
// get the tabs list from the JSON file
$tabs = $gk_tpl->get_json('options', 'tabs');
// iterators
$tabsIterator = 0;
$contentIterator = 0;
// active tab
$activeTab = 0;
if (isset($_COOKIE[GKTPLNAME . '_active_tab']) && is_numeric($_COOKIE[GKTPLNAME . '_active_tab'])) {
    $activeTab = floor($_COOKIE[GKTPLNAME . '_active_tab']);
}
?>

<div class="gkWrap" id="gkMainWrap" data-theme="<?php 
echo GKTPLNAME;
?>
">	
	<h1>
		<big><?php 
echo $gk_tpl->full_name;
?>
</big><small><?php 
<?php

/**
 * 
 * GK Tweets Widget class
 *
 **/
require_once gavern_file('gavern/classes/class.gkoauth.php');
class GK_Tweets_Widget extends WP_Widget
{
    /**
     *
     * Constructor
     *
     * @return void
     *
     **/
    function __construct()
    {
        $widget_ops = array('classname' => 'widget_gk_tweets', 'description' => __('Use this widget to show recent tweets for specific query', GKTPLNAME));
        parent::__construct('widget_gk_tweets', __('GK Tweets Widget', GKTPLNAME), $widget_ops);
        $this->alt_option_name = 'widget_gk_tweets';
    }
    /**
     *
     * Outputs the HTML code of this widget.
     *
     * @param array An array of standard parameters for widgets in this theme
     * @param array An array of settings for this widget instance
     * @return void
     *
// disable direct access to the file
defined('GAVERN_WP') or die('Access denied');
/**
 *
 * Main functions
 *
 * Functions used to creacte dashboard menus.
 *
 **/
// load file with Template Options page
require_once gavern_file('gavern/options.template.php');
// load file with Updates Options page
require_once gavern_file('gavern/options.updates.php');
// load file with Import/Export settings page
require_once gavern_file('gavern/options.importexport.php');
/**
 *
 * Function to add menu items in the admin panel
 *
 **/
if (!function_exists('gavern_admin_menu')) {
    function gavern_admin_menu()
    {
        // getting access to the template global object.
        global $tpl;
        // set the default icon path
        $icon_path = gavern_file_uri('images/back-end/small_logo.png');
        // check if user set his own icon and then replace the default path
        if (get_option($tpl->name . "_branding_admin_page_image") != '') {
            $icon_path = get_option($tpl->name . "_branding_admin_page_image");