/** * * Function used to load updates page CSS code * * @return null * **/ function gavern_updates_options_css() { // variable used for the page detection global $pagenow; // check the page if ($pagenow == 'admin.php' && isset($_GET['page']) && ($_GET['page'] == 'updates_options' || $_GET['page'] == 'updates_options')) { wp_register_style('gk-updates-css', gavern_file_uri('css/back-end/updates.css')); wp_enqueue_style('gk-updates-css'); } }
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"); } // creating main menu item for the template settings $plugin_page = add_object_page('GavernWP Framework', $tpl->config['template']->name, 'manage_options', 'gavern-menu', 'gavern_template_options', $icon_path); // checking if showing template options is enabled if ($tpl->config['developer_config']->visibility->template_options == 'true') { // $plugin_page = add_submenu_page('gavern-menu', $tpl->config['template']->name, __('Template options', GKTPLNAME), 'manage_options', 'gavern-menu', 'gavern_template_options'); // save callback add_action("admin_head-" . $plugin_page, 'gavern_template_save_js'); // adding scripts and stylesheets add_action('admin_print_scripts', 'gavern_template_options_js'); add_action('admin_print_styles', 'gavern_template_options_css'); } // checking if showing import/export options is enabled if ($tpl->config['developer_config']->visibility->importexport == 'true') { // $plugin_page = add_submenu_page('gavern-menu', $tpl->config['template']->name, __('Import/Export', GKTPLNAME), 'manage_options', 'importexport_options', 'gavern_importexport_options'); } // checking if showing Update options is enabled if ($tpl->config['developer_config']->visibility->updates == 'true') { // $plugin_page = add_submenu_page('gavern-menu', $tpl->config['template']->name, __('Updates', GKTPLNAME), 'manage_options', 'updates_options', 'gavern_updates_options'); // adding scripts and stylesheets add_action('admin_print_scripts', 'gavern_updates_options_js'); add_action('admin_print_styles', 'gavern_updates_options_css'); } // checking if showing documentation options is enabled if ($tpl->config['developer_config']->visibility->documentation == 'true') { // $plugin_page = add_submenu_page('gavern-menu', $tpl->config['template']->name, __('Documentation', GKTPLNAME), 'manage_options', 'themes.php?goto=wiki'); } // checking if showing GavickPro information is enabled if ($tpl->config['developer_config']->visibility->gavickpro_website == 'true') { // $plugin_page = add_submenu_page('gavern-menu', $tpl->config['template']->name, __('GavickPro Website', GKTPLNAME), 'manage_options', 'themes.php?goto=gavick-com'); } }
function gavern_ts_themeurl($atts) { // return the theme directory url return gavern_file_uri(false); }
<?php /* Template Name: Gallery Page */ global $gk_tpl; gk_load('header', array('css' => gavern_file_uri('css/templates/gallery.css'), 'js' => gavern_file_uri('js/templates/gallery.js'))); gk_load('before'); ?> <section id="gk-mainbody"> <?php the_post(); ?> <h1 class="page-title"><?php the_title(); ?> </h1> <article class="gallery-page"> <section class="intro"> <?php // Load images $images = get_children(array('numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image', 'post_parent' => $post->ID, 'post_status' => null, 'post_type' => 'attachment')); ?> <?php if ($images) { ?> <section id="gallery">
function gavern_enqueue_admin_js_and_css() { // metaboxes scripts wp_enqueue_script('gavern.metabox.js', gavern_file_uri('js/back-end/gavern.metabox.js')); // widget rules JS wp_register_script('widget-rules-js', gavern_file_uri('js/back-end/widget.rules.js'), array('jquery')); wp_enqueue_script('widget-rules-js'); // widget rules CSS wp_register_style('widget-rules-css', gavern_file_uri('css/back-end/widget.rules.css')); wp_enqueue_style('widget-rules-css'); // metaboxes CSS wp_register_style('gavern-metabox-css', gavern_file_uri('css/back-end/metabox.css')); wp_enqueue_style('gavern-metabox-css'); // GK News Show Pro Widget back-end CSS wp_register_style('nsp-admin-css', gavern_file_uri('css/back-end/nsp.css')); wp_enqueue_style('nsp-admin-css'); // shortcodes database if (get_locale() != '' && is_dir(get_template_directory() . '/gavern/config/' . get_locale()) && is_dir(get_template_directory() . '/gavern/options/' . get_locale())) { $language = get_locale(); } else { $language = 'en_US'; } wp_enqueue_script('shortcodes.js', gavern_file_uri('gavern/config/' . $language . '/shortcodes.js')); }
/** * * Function used to generate scripts connected with the IE browser in the <head> section * **/ function gavernwp_ie_scripts_hook() { // generate scripts connected with IE9 echo '<!--[if lt IE 9]>' . "\n"; echo '<script src="' . gavern_file_uri('js/html5shiv.js') . '"></script>' . "\n"; echo '<script src="' . gavern_file_uri('js/respond.js') . '"></script>' . "\n"; echo '<![endif]-->' . "\n"; // YOUR HOOK CODE HERE }
} ?> </div> <?php } ?> </div> <?php } ?> <?php if (get_option($tpl->name . '_template_footer_logo', 'Y') == 'Y') { ?> <img src="<?php echo gavern_file_uri('images/gavernwp.png'); ?> " class="gk-framework-logo" alt="GavernWP" /> <?php } ?> <p class="gk-disclaimer">Copyright © 2012. Designed by <a href="http://www.gavick.com">GavickPro</a> - High quality free WordPress Themes</p> <p class="gk-disclaimer">Icons from <a href="http://glyphicons.com">Glyphicons Free</a>, licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a></p> </footer> <?php if (gk_is_active_sidebar('social')) { ?> <div id="gk-social-icons" class="<?php echo get_option($tpl->name . '_social_icons_position', 'right');
function gavern_importexport_options() { // getting access to the template and database global object. global $tpl; global $wpdb; wp_register_style('gk-import-export-css', gavern_file_uri('css/back-end/importexport.css')); wp_enqueue_style('gk-import-export-css'); // check permissions if (!current_user_can('manage_options')) { wp_die(__('You don\'t have sufficient permissions to access this page!', GKTPLNAME)); } // Import Starts Here ?> <div class="gkWrap wrap"> <h1><big><?php echo $tpl->full_name; ?> </big><small><?php _e('Based on the Gavern WP framework', GKTPLNAME); ?> </small></h1> <div class="gkImport"> <h2>Import Template Settings</h2> <?php if (isset($_FILES['import']) && check_admin_referer('gavern_importexport')) { if ($_FILES['import']['error'] > 0) { echo "<div class='error'><p>No file selected, please make sure to select a file.</p></div>"; } else { $file_name = $_FILES['import']['name']; $file_ext = strtolower(end(explode(".", $file_name))); $file_size = $_FILES['import']['size']; if ($file_ext == "json" && $file_size < 10000) { $encode_options = file_get_contents($_FILES['import']['tmp_name']); $options = json_decode($encode_options, true); if (is_array($options) && count($options) > 0) { foreach ($options as $key => $value) { update_option($key, esc_attr($value)); } } echo "<div class='updated'><p>All template options are restored successfully.</p></div>"; } else { echo "<div class='error'><p>Invalid file or file size too big.</p></div>"; } } } ?> <p>1. Click "Browse" button and choose a backup file that you backup before.</p> <p>2. Click "Restore Template Settings" button to restore your template settings.</p> <form method='post' enctype='multipart/form-data'> <p class="submit"> <?php wp_nonce_field('gavern_importexport'); ?> <input type='file' name='import' /> <input type='submit' name='submit' class="gkMedia" value='Restore Template Settings'/> </p> </form> </div> <?php // Export Starts Here if (!isset($_POST['export'])) { ?> <div class="gkExport"> <h2>Export Template Settings</h2> <p>When you click "Backup Template Settings" button, system will generate a template backup file for you to save on your computer.</p> <p>This backup file contains your Gavern template configuration and setting options.</p> <p>After exporting, you can either use the backup file to restore your template settings on this site again or another Wordpress site when using same Gavern template.</p> <form method='post'> <p class="submit"> <?php wp_nonce_field('gavern_importexport'); ?> <input type='submit' name='export' class="gkMedia" value='Backup Template Settings'/> </p> </form> </div> <?php } elseif (check_admin_referer('gavern_importexport')) { $option_prefix = $tpl->name; $blogname = str_replace(" ", "", get_option('blogname')); $date = date("d_m_Y_H_i_s"); $json_name = $blogname . "_" . $tpl->name . "_" . $date; // Generating filename. // get all rows with options containing specific prefix $options = $wpdb->get_results('SELECT option_value, option_name FROM ' . $wpdb->options . ' WHERE option_name LIKE \'' . $option_prefix . '%\';'); $value = array(); if ($options) { foreach ($options as $key) { if ($key->option_name != $tpl->name . '_widget_responsive' && $key->option_name != $tpl->name . '_widget_rules' && $key->option_name != $tpl->name . '_widget_rules_type' && $key->option_name != $tpl->name . '_widget_style' && $key->option_name != $tpl->name . '_widget_style_css' && $key->option_name != $tpl->name . '_widget_users') { $value[$key->option_name] = $key->option_value; } } } $json_file = json_encode($value); // Encode data into json data ob_clean(); echo $json_file; header("Content-Type: text/json; charset=" . get_option('blog_charset')); header("Content-Disposition: attachment; filename={$json_name}.json"); exit; } ?> </div> <?php // Export Ends Here }
<?php do_action('gavernwp_fonts'); ?> <?php gk_head_config(); ?> <?php wp_enqueue_script("jquery"); ?> <?php wp_enqueue_script('gavern-scripts', gavern_file_uri('js/gk.scripts.js'), array('jquery'), false, true); wp_enqueue_script('gavern-menu', gavern_file_uri('js/gk.menu.js'), array('jquery', 'gavern-scripts'), false, true); wp_enqueue_script('gavern-modernizr', gavern_file_uri('js/modernizr.js'), false, false, true); wp_enqueue_script('gavern-scrollreveal', gavern_file_uri('js/scrollreveal.js'), false, false, true); ?> <?php do_action('gavernwp_head'); ?> <?php if (is_page_template('template.contact.php') && get_option($gk_tpl->name . '_recaptcha_state', 'N') == 'Y' && get_option($gk_tpl->name . '_recaptcha_public_key', '') != '' && get_option($gk_tpl->name . '_recaptcha_private_key', '') != '') { wp_enqueue_script('gk-captcha-script', 'https://www.google.com/recaptcha/api.js', array('jquery'), false, false); } ?> <?php echo stripslashes(htmlspecialchars_decode(str_replace(''', "'", get_option($gk_tpl->name . '_head_code', '')))); ?>
wp_head(); ?> <?php do_action('gavernwp_fonts'); ?> <?php gk_head_config(); ?> <?php wp_enqueue_script("jquery"); ?> <?php wp_enqueue_script('gavern-scripts', gavern_file_uri('js/gk.scripts.js'), array('jquery'), false, true); wp_enqueue_script('gavern-menu', gavern_file_uri('js/gk.menu.js'), array('jquery', 'gavern-scripts'), false, true); ?> <?php do_action('gavernwp_head'); ?> <?php echo stripslashes(htmlspecialchars_decode(str_replace(''', "'", get_option($tpl->name . '_head_code', '')))); ?> </head> <body <?php do_action('gavernwp_body_attributes'); ?> > <header id="gk-head">
/** * * Function used to create links to stylesheets and script files for specific pages * * @return HTML output * **/ function gk_head_style_pages() { // get access to the template object global $tpl; // scripts for the contact page if (is_page_template('contact.php')) { wp_enqueue_script('gavern-contact-validate', gavern_file_uri('js/jquery.validate.min.js'), array('jquery', 'gavern-scripts'), false, true); wp_enqueue_script('gavern-contact-main', gavern_file_uri('js/contact.js'), array('jquery', 'gavern-scripts'), false, true); } }
/** * * Function used as real die handler * * @param message - message for the error page * @param title - title of the error page * @param args - additional params * * @return null * **/ function gavern_custom_die_handler($message, $title = '', $args = array()) { if (!defined('GKTPLNAME')) { define('GKTPLNAME', 'MeetGavernWP'); } $defaults = array('response' => 404); $r = wp_parse_args($args, $defaults); $have_gettext = function_exists('__'); if (function_exists('is_wp_error') && is_wp_error($message)) { if (empty($title)) { $error_data = $message->get_error_data(); if (is_array($error_data) && isset($error_data['title'])) { $title = $error_data['title']; } } $errors = $message->get_error_messages(); switch (count($errors)) { case 0: $message = ''; break; case 1: $message = "<p>{$errors[0]}</p>"; break; default: $message = "<ul>\n\t\t<li>" . join("</li>\n\t\t<li>", $errors) . "</li>\n\t</ul>"; break; } } elseif (is_string($message)) { $message = "<p>{$message}</p>"; } if (isset($r['back_link']) && $r['back_link']) { $back_text = $have_gettext ? __('« Back', GKTPLNAME) : '« Back'; $message .= "\n<p><a href='javascript:history.back()'>{$back_text}</a></p>"; } if (!function_exists('did_action') || !did_action('admin_head')) { if (!headers_sent()) { status_header($r['response']); nocache_headers(); header('Content-Type: text/html; charset=utf-8'); } if (empty($title)) { $title = $have_gettext ? __('WordPress › Error', GKTPLNAME) : 'WordPress › Error'; } $text_direction = 'ltr'; if (isset($r['text_direction']) && 'rtl' == $r['text_direction']) { $text_direction = 'rtl'; } elseif (function_exists('is_rtl') && is_rtl()) { $text_direction = 'rtl'; } ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" <?php if (function_exists('language_attributes') && function_exists('is_rtl')) { language_attributes(); } else { echo "dir='{$text_direction}'"; } ?> > <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $title; ?> </title> <link href="<?php echo gavern_file_uri('fonts/Colaborate/stylesheet.css'); ?> " rel="stylesheet" type="text/css" /> <link href="<?php echo gavern_file_uri('css/error.css'); ?> " rel="stylesheet" type="text/css" /> </head> <body id="error-page"> <?php } ?> <a href="./index.php" class="cssLogo"><?php echo $title; ?> </a> <h1><?php echo str_replace('WordPress › ', '', $title); ?> </h1> <?php echo $message; ?> <p class="errorinfo"><a href="./index.php"><?php _e('Homepage', GKTPLNAME); ?> </a></p> </body> </html> <?php die; }
function gavern_opensearch() { // access to the wp_query variable global $wp_query; // check if there was an variable opensearch_description in the query vars if (!empty($wp_query->query_vars['opensearch_description'])) { // if yes - return the XML with OpenSearch description header('Content-Type: text/xml'); // the XML content echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; echo "<OpenSearchDescription xmlns=\"http://a9.com/-/spec/opensearch/1.1/\">\n"; echo "\t<ShortName>" . get_bloginfo('name') . "</ShortName>\n"; echo "\t<LongName>" . get_bloginfo('name') . "</LongName>\n"; echo "\t<Description>Search "" . get_bloginfo('name') . ""</Description>\n"; echo "\t<Image width=\"16\" height=\"16\" type=\"image/x-icon\">" . gavern_file_uri('favicon.ico') . "</Image>\n"; echo "\t<Contact>" . get_bloginfo('admin_email') . "</Contact>\n"; echo "\t<Url type=\"text/html\" template=\"" . get_bloginfo('url') . "/?s={searchTerms}\"/>\n"; echo "\t<Url type=\"application/atom+xml\" template=\"" . get_bloginfo('url') . "/?feed=atom&s={searchTerms}\"/>\n"; echo "\t<Url type=\"application/rss+xml\" template=\"" . get_bloginfo('url') . "/?feed=rss2&s={searchTerms}\"/>\n"; echo "\t<Language>" . get_bloginfo('language') . "</Language>\n"; echo "\t<OutputEncoding>" . get_bloginfo('charset') . "</OutputEncoding>\n"; echo "\t<InputEncoding>" . get_bloginfo('charset') . "</InputEncoding>\n"; echo "</OpenSearchDescription>"; exit; } // if not just end the function return; }
%; } <?php } else { ?> #gk-mainbody-columns > section { width: 100%; } <?php } ?> @media (min-width: <?php echo get_option($tpl->name . '_tablet_width', '800') + 1; ?> px) { #gk-mainmenu-collapse { height: auto!important; } } </style> <?php // check the dependicies for the tablet.css file if (get_option($tpl->name . "_shortcodes3_state", 'Y') == 'Y') { wp_enqueue_style('gavern-tablet', gavern_file_uri('css/tablet.css'), array('gavern-shortcodes-template'), false, '(max-width: ' . get_option($tpl->name . '_tablet_width', '800') . 'px)'); } elseif (get_option($tpl->name . "_shortcodes2_state", 'Y') == 'Y') { wp_enqueue_style('gavern-tablet', gavern_file_uri('css/tablet.css'), array('gavern-shortcodes-elements'), false, '(max-width: ' . get_option($tpl->name . '_tablet_width', '800') . 'px)'); } elseif (get_option($tpl->name . "_shortcodes1_state", 'Y') == 'Y') { wp_enqueue_style('gavern-tablet', gavern_file_uri('css/tablet.css'), array('gavern-shortcodes-typography'), false, '(max-width: ' . get_option($tpl->name . '_tablet_width', '800') . 'px)'); } else { wp_enqueue_style('gavern-tablet', gavern_file_uri('css/tablet.css'), array('gavern-extensions'), false, '(max-width: ' . get_option($tpl->name . '_tablet_width', '800') . 'px)'); } // mobile.css is always loaded after the tablet.css file wp_enqueue_style('gavern-mobile', gavern_file_uri('css/mobile.css'), array('gavern-tablet'), false, '(max-width: ' . get_option($tpl->name . '_mobile_width', '800') . 'px)'); // EOF
/** * * Function used to load template options CSS code * * @return null * **/ function gavern_template_options_css() { // variable used for the page detection global $pagenow; // template object global $tpl; // check the page if ($pagenow == 'admin.php' && isset($_GET['page']) && ($_GET['page'] == 'template_options' || $_GET['page'] == 'gavern-menu')) { wp_enqueue_style('thickbox'); wp_register_style('gk-tips-css', gavern_file_uri('js/back-end/libraries/miniTip/miniTip.css')); wp_register_style('gk-template-css', gavern_file_uri('css/back-end/template.css')); wp_enqueue_style('gk-tips-css'); wp_enqueue_style('gk-template-css'); // register and load external components scripts $tabs = $tpl->get_json('options', 'tabs'); // iterate through tabs foreach ($tabs as $tab) { if ($tab[2] == 'enabled') { // load file $loaded_data = $tpl->get_json('options', $tab[1]); // check the loaded JSON data if ($loaded_data != null && count($loaded_data != 0)) { $standard_fields = array('Text', 'Select', 'Switcher', 'Textarea', 'Media', 'WidthHeight', 'TextBlock'); // iterate through groups foreach ($loaded_data as $group) { // foreach ($group->fields as $field) { if (!in_array($field->type, $standard_fields)) { // load field config $file_config = $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 the CSS file if ($file_config->css != '') { wp_register_style('gk_' . strtolower($file_config->name) . '.css', gavern_file_uri('gavern/form_elements/') . $field->type . '/' . $file_config->css); wp_enqueue_style('gk_' . strtolower($file_config->name) . '.css'); } } } } } } } } } }
static function add_scripts() { wp_register_script('gk-nsp', gavern_file_uri('js/widgets/nsp.js'), array('jquery'), false, true); wp_enqueue_script('gk-nsp'); }