// SYSTEM PANEL //
[ROOT]
/
home
/
salvufkx
/
public_html
/
wp-contentmmm
/
themes
/
vega
[ PARENT ]
EDIT :: functions.php
<?php //Get theme data $theme_obj = wp_get_theme('vega'); define("THEMENAME", $theme_obj['Name']); define("THEMEDEMO", FALSE); define("SHORTNAME", "pp"); define("SKINSHORTNAME", "ps"); define("THEMEVERSION", $theme_obj['Version']); define("THEMEDOMAIN", THEMENAME.'Language'); define("THEMEDEMOURL", $theme_obj['ThemeURI']); define("THEMEDATEFORMAT", get_option('date_format')); define("THEMETIMEFORMAT", get_option('time_format')); //Get default WP uploads folder $wp_upload_arr = wp_upload_dir(); define("THEMEUPLOAD", $wp_upload_arr['basedir']."/".strtolower(THEMENAME)."/"); define("THEMEUPLOADURL", $wp_upload_arr['baseurl']."/".strtolower(THEMENAME)."/"); /** * Defined all custom font elements **/ $gg_fonts = array(SHORTNAME.'_menu_font', SHORTNAME.'_sidebar_title_font', SHORTNAME.'_header_font', SHORTNAME.'_body_font', SHORTNAME.'_gallery_cover_title_font'); global $gg_fonts; load_theme_textdomain( THEMEDOMAIN, get_template_directory().'/languages' ); $locale = get_locale(); $locale_file = get_template_directory()."/languages/$locale.php"; if ( is_readable($locale_file) ) { require_once($locale_file); } //If restore default theme settings if(is_admin() && isset($_POST['pp_restore_flg']) && !empty($_POST['pp_restore_flg']) && $_GET["page"] == "functions.php") { global $wpdb; //Inject SQL for default setting include_once(get_template_directory() . "/restore.php"); } //If clear cache if(is_admin() && isset($_POST['method']) && !empty($_POST['method']) && $_POST['method'] == 'clear_cache') { if(file_exists(get_template_directory()."/cache/combined.js")) { unlink(get_template_directory()."/cache/combined.js"); } if(file_exists(get_template_directory()."/cache/combined.css")) { unlink(get_template_directory()."/cache/combined.css"); } exit; } //If delete sidebar if(is_admin() && isset($_POST['sidebar_id']) && !empty($_POST['sidebar_id'])) { $current_sidebar = get_option('pp_sidebar'); if(isset($current_sidebar[ $_POST['sidebar_id'] ])) { unset($current_sidebar[ $_POST['sidebar_id'] ]); update_option( "pp_sidebar", $current_sidebar ); } echo 1; exit; } //If delete ggfont if(is_admin() && isset($_POST['ggfont']) && !empty($_POST['ggfont'])) { $current_ggfont = get_option('pp_ggfont'); if(isset($current_ggfont[ $_POST['ggfont'] ])) { unset($current_ggfont[ $_POST['ggfont'] ]); update_option( "pp_ggfont", $current_ggfont ); } echo 1; exit; } //If delete image if(isset($_POST['field_id']) && !empty($_POST['field_id']) && isset($_GET["page"]) && $_GET["page"] == "functions.php" ) { $current_val = get_option($_POST['field_id']); delete_option( $_POST['field_id'] ); echo 1; exit; } //If import default settings if(is_admin() && isset($_POST['pp_import_default']) && !empty($_POST['pp_import_default'])) { global $wpdb; $demo_style = 1; if(!isset($_POST['pp_import_demo']) OR empty($_POST['pp_import_demo'])) { $_POST['pp_import_demo'] = 1; } else { $demo_style = $_POST['pp_import_demo']; } $default_json_settings = get_template_directory().'/cache/demos/'.$demo_style.'.json'; if(file_exists($default_json_settings)) { $import_options_json = file_get_contents($default_json_settings); $import_options_arr = json_decode($import_options_json, true); if(!empty($import_options_arr) && is_array($import_options_arr)) { foreach($import_options_arr as $key => $import_option) { $wpdb->query($wpdb->prepare( "DELETE FROM `".$wpdb->prefix."options` WHERE option_name = %s", array( $key ) )); $wpdb->query($wpdb->prepare( "INSERT IGNORE INTO `".$wpdb->prefix."options` (`option_name`, `option_value`, `autoload`) VALUES(%s, %s, %s);", array( $key, $import_option, 'yes' ) )); } } } header("Location: admin.php?page=functions.php&saved=true".$_REQUEST['current_tab']); exit; } //If import settings if(is_admin() && isset($_FILES['pp_import_current']["tmp_name"]) && !empty($_FILES['pp_import_current']["tmp_name"])) { global $wpdb; $import_options_json = file_get_contents($_FILES["pp_import_current"]["tmp_name"]); $import_options_arr = json_decode($import_options_json, true); if(!empty($import_options_arr) && is_array($import_options_arr)) { foreach($import_options_arr as $key => $import_option) { $wpdb->query($wpdb->prepare( "DELETE FROM `".$wpdb->prefix."options` WHERE option_name = %s", array( $key ) )); $wpdb->query($wpdb->prepare( "INSERT IGNORE INTO `".$wpdb->prefix."options` (`option_name`, `option_value`, `autoload`) VALUES(%s, %s, %s);", array( $key, $import_option, 'yes' ) )); } } header("Location: admin.php?page=functions.php&saved=true".$_REQUEST['current_tab']); exit; } //If export settings if(is_admin() && isset($_POST['pp_export_current']) && !empty($_POST['pp_export_current'])) { $json_file_name = THEMENAME.'_Theme_Export_'.date('m-d-Y_hia'); header('Content-disposition: attachment; filename='.$json_file_name.'.json'); header('Content-type: application/json'); /** * Setup admin setting **/ include_once (get_template_directory() . "/lib/admin.lib.php"); $export_options_arr = array(); if(isset($options) && !empty($options) && is_array($options)) { foreach ($options as $value) { if(isset($value['id']) && !empty($value['id'])) { $export_options_arr[$value['id']] = get_option($value['id']); } } } echo json_encode($export_options_arr); exit; } /* * Setup main navigation menu */ add_action( 'init', 'register_my_menu' ); function register_my_menu() { register_nav_menu( 'left-menu', __( 'Main Menu Left Side', THEMEDOMAIN ) ); register_nav_menu( 'right-menu', __( 'Main Menu Right Side', THEMEDOMAIN ) ); } if ( function_exists( 'add_theme_support' ) ) { // Setup thumbnail support add_theme_support( 'post-thumbnails' ); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'woocommerce' ); } if ( function_exists( 'add_image_size' ) ) { add_image_size( 'gallery_c', 485, 485, true ); add_image_size( 'gallery_cl', 700, 702, true ); add_image_size( 'gallery_cm', 485, 9999, false ); add_image_size( 'blog', 960, 9999, false ); } /** * Setup all theme's library **/ /** * Setup admin setting **/ include (get_template_directory() . "/lib/admin.lib.php"); include (get_template_directory() . "/lib/twitter.lib.php"); $pp_advance_combine_css = get_option('pp_advance_combine_css'); if (!empty($pp_advance_combine_css) && !class_exists('CSSMin')) { include (get_template_directory() . "/lib/cssmin.lib.php"); } $pp_advance_combine_js = get_option('pp_advance_combine_js'); if (!empty($pp_advance_combine_js) && !class_exists('JSMin')) { include (get_template_directory() . "/lib/jsmin.lib.php"); } /** * Setup Sidebar **/ include (get_template_directory() . "/lib/sidebar.lib.php"); //Get custom function include (get_template_directory() . "/lib/custom.lib.php"); // Get Content Builder Module include (get_template_directory() . "/lib/contentbuilder.lib.php"); //Get custom shortcode include (get_template_directory() . "/lib/shortcode.lib.php"); // Setup theme custom widgets include (get_template_directory() . "/lib/widgets.lib.php"); include (get_template_directory() . "/fields/page.fields.php"); include (get_template_directory() . "/fields/post.fields.php"); include (get_template_directory() . "/fields/gallery/tg-gallery.php"); //Check if has new update //include_once(get_template_directory() . '/modules/envato-wordpress-toolkit-library/class-envato-wordpress-theme-upgrader.php'); //Check if Woocommerce is installed if(class_exists('Woocommerce')) { //Setup Woocommerce Config require_once (get_template_directory() . "/modules/woocommerce.php"); } /*$pp_envato_username = get_option('pp_envato_username'); $pp_envato_api_key = get_option('pp_envato_api_key'); $upgrader = array(); if(!empty($pp_envato_username) && !empty($pp_envato_api_key)) { $upgrader = new Envato_WordPress_Theme_Upgrader( $pp_envato_username, $pp_envato_api_key ); $upgrader_obj = $upgrader->check_for_theme_update(); if($upgrader_obj->updated_themes_count > 0) { add_action('admin_notices', 'pp_admin_notice'); function pp_admin_notice() { global $current_user ; $user_id = $current_user->ID; if ( ! get_user_meta($user_id, 'pp_ignore_notice') ) { echo '<div class="updated"><p>'; printf(__(' There is update available for '.THEMENAME.' theme. Go to "Theme Setting > Auto update" tab to update the theme. | <a href="%1$s">Hide</a>'), '?pp_ignore_notice=0'); echo "</p></div>"; } } add_action('admin_init', 'pp_nag_ignore'); function pp_nag_ignore() { global $current_user; $user_id = $current_user->ID; if ( isset($_GET['pp_ignore_notice']) && '0' == $_GET['pp_ignore_notice'] ) { add_user_meta($user_id, 'pp_ignore_notice', 'true', true); } } } }*/ /** * Setup one click update theme function **/ /*add_action('wp_ajax_pp_update_theme', 'pp_update_theme'); add_action('wp_ajax_nopriv_pp_update_theme', 'pp_update_theme'); function pp_update_theme() { if(is_admin()) { include_once(get_template_directory() . '/modules/envato-wordpress-toolkit-library/class-envato-wordpress-theme-upgrader.php'); $pp_envato_username = get_option('pp_envato_username'); $pp_envato_api_key = get_option('pp_envato_api_key'); if(!empty($pp_envato_username) && !empty($pp_envato_api_key)) { $upgrader = new Envato_WordPress_Theme_Upgrader( $pp_envato_username, $pp_envato_api_key ); $upgrader_obj = $upgrader->check_for_theme_update(); if($upgrader_obj->updated_themes_count > 0) { $result = $upgrader->upgrade_theme(); echo $result->installation_feedback; } else { echo 'There is no theme update available'; } } else { echo 'Please enter Envato username and API Key'; } } }*/ /** * Setup AJAX portfolio function **/ add_action('wp_ajax_pp_ajax_portfolio', 'pp_ajax_portfolio'); add_action('wp_ajax_nopriv_pp_ajax_portfolio', 'pp_ajax_portfolio'); function pp_ajax_portfolio() { if(isset($_GET['portfolio_id'])) { $single_portoflio_post = get_post($_GET['portfolio_id']); echo pp_apply_content(do_shortcode($single_portoflio_post->post_content)); } die(); } /** * Setup contact form mailing function **/ add_action('wp_ajax_pp_contact_mailer', 'pp_contact_mailer'); add_action('wp_ajax_nopriv_pp_contact_mailer', 'pp_contact_mailer'); function pp_contact_mailer() { check_ajax_referer( 'tgajax-post-contact-nonce', 'tg_security' ); //Error message when message can't send define('ERROR_MESSAGE', 'Oops! something went wrong, please try to submit later.'); if (isset($_POST['your_name'])) { //Get your email address $contact_email = get_option('pp_contact_email'); $pp_contact_thankyou = __( 'Thank you! We will get back to you as soon as possible', THEMEDOMAIN ); /* | | Begin sending mail | */ $from_name = $_POST['your_name']; $from_email = $_POST['email']; //Get contact subject if(!isset($_POST['subject'])) { $contact_subject = __( 'Email from contact form', THEMEDOMAIN ); } else { $contact_subject = $_POST['subject']; } $headers = ""; //$headers.= 'From: '.$from_name.'<'.$from_email.'>'.PHP_EOL; $headers.= 'Reply-To: '.$from_name.'<'.$from_email.'>'.PHP_EOL; $headers.= 'Return-Path: '.$from_name.'<'.$from_email.'>'.PHP_EOL; $message = 'Name: '.$from_name.PHP_EOL; $message.= 'Email: '.$from_email.PHP_EOL.PHP_EOL; $message.= 'Message: '.PHP_EOL.$_POST['message'].PHP_EOL.PHP_EOL; if(isset($_POST['address'])) { $message.= 'Address: '.$_POST['address'].PHP_EOL; } if(isset($_POST['phone'])) { $message.= 'Phone: '.$_POST['phone'].PHP_EOL; } if(isset($_POST['mobile'])) { $message.= 'Mobile: '.$_POST['mobile'].PHP_EOL; } if(isset($_POST['company'])) { $message.= 'Company: '.$_POST['company'].PHP_EOL; } if(isset($_POST['country'])) { $message.= 'Country: '.$_POST['country'].PHP_EOL; } if(!empty($from_name) && !empty($from_email) && !empty($message)) { wp_mail($contact_email, $contact_subject, $message, $headers); echo '<p>'.$pp_contact_thankyou.'</p>'; die; } else { echo '<p>'.ERROR_MESSAGE.'</p>'; die; } } else { echo '<p>'.ERROR_MESSAGE.'</p>'; } die(); } /** * Setup image proofing function **/ add_action('wp_ajax_vega_image_proofing', 'vega_image_proofing'); add_action('wp_ajax_nopriv_vega_image_proofing', 'vega_image_proofing'); function vega_image_proofing() { if(!THEMEDEMO) { check_ajax_referer( 'tgajax-post-contact-nonce', 'tg_security' ); $gallery_id = ''; $image_id = ''; if(isset($_POST['gallery_id'])) { $gallery_id = $_POST['gallery_id']; } if(isset($_POST['image_id'])) { $image_id = $_POST['image_id']; } if(isset($_POST['method']) && $_POST['method'] == 'approve') { //Get current approved images $current_images_approve = get_post_meta($gallery_id, 'gallery_images_approve', true); if(!empty($current_images_approve)) { if ( !in_array( $image_id, $current_images_approve ) ) { $current_images_approve[] = $image_id; } $current_images_approve = array_unique($current_images_approve); update_post_meta($gallery_id, 'gallery_images_approve', $current_images_approve); } else { $current_images_approve[] = $image_id; $current_images_approve = array_unique($current_images_approve); update_post_meta($gallery_id, 'gallery_images_approve', $current_images_approve); } } else if(isset($_POST['method']) && $_POST['method'] == 'unapprove') { //Get current approved images $current_images_approve = get_post_meta($gallery_id, 'gallery_images_approve', true); if(!empty($current_images_approve)) { if (($key = array_search($image_id, $current_images_approve)) !== false) { unset($current_images_approve[$key]); } update_post_meta($gallery_id, 'gallery_images_approve', $current_images_approve); } } } die(); } /** * End image proofing function **/ function pp_add_admin() { global $themename, $shortname, $options, $pp_include_from_skin_arr; if ( isset($_GET['page']) && $_GET['page'] == basename(__FILE__) ) { if ( isset($_REQUEST['action']) && 'save' == $_REQUEST['action'] ) { foreach ($options as $value) { if($value['type'] != 'image' && isset($value['id']) && isset($_REQUEST[ $value['id'] ])) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } } foreach ($options as $value) { if( isset($value['id']) && isset( $_REQUEST[ $value['id'] ] )) { if($value['id'] != SHORTNAME."_sidebar0" && $value['id'] != SHORTNAME."_ggfont0") { //if sortable type if(is_admin() && $value['type'] == 'sortable') { $sortable_array = serialize($_REQUEST[ $value['id'] ]); $sortable_data = $_REQUEST[ $value['id'].'_sort_data']; $sortable_data_arr = explode(',', $sortable_data); $new_sortable_data = array(); foreach($sortable_data_arr as $key => $sortable_data_item) { $sortable_data_item_arr = explode('_', $sortable_data_item); if(isset($sortable_data_item_arr[0])) { $new_sortable_data[] = $sortable_data_item_arr[0]; } } update_option( $value['id'], $sortable_array ); update_option( $value['id'].'_sort_data', serialize($new_sortable_data) ); } elseif(is_admin() && $value['type'] == 'font') { if(!empty($_REQUEST[ $value['id'] ])) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); update_option( $value['id'].'_value', $_REQUEST[ $value['id'].'_value' ] ); } else { delete_option( $value['id'] ); delete_option( $value['id'].'_value' ); } } elseif(is_admin()) { if($value['type']=='image') { update_option( $value['id'], esc_url($_REQUEST[ $value['id'] ]) ); } elseif($value['type']=='textarea') { update_option( $value['id'], esc_textarea($_REQUEST[ $value['id'] ]) ); } elseif($value['type']=='iphone_checkboxes' OR $value['type']=='jslider') { update_option( $value['id'], intval($_REQUEST[ $value['id'] ]) ); } update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } } elseif(is_admin() && isset($_REQUEST[ $value['id'] ]) && !empty($_REQUEST[ $value['id'] ])) { if($value['id'] == SHORTNAME."_sidebar0") { //get last sidebar serialize array $current_sidebar = get_option(SHORTNAME."_sidebar"); $current_sidebar[ $_REQUEST[ $value['id'] ] ] = $_REQUEST[ $value['id'] ]; update_option( SHORTNAME."_sidebar", $current_sidebar ); } elseif($value['id'] == SHORTNAME."_ggfont0") { //get last ggfonts serialize array $current_ggfont = get_option(SHORTNAME."_ggfont"); $current_ggfont[ $_REQUEST[ $value['id'] ] ] = $_REQUEST[ $value['id'] ]; update_option( SHORTNAME."_ggfont", $current_ggfont ); } } } else { if(is_admin() && isset($value['id'])) { delete_option( $value['id'] ); } } } header("Location: admin.php?page=functions.php&saved=true".$_REQUEST['current_tab']); } } add_menu_page('Theme Setting', 'Theme Setting', 'administrator', basename(__FILE__), 'pp_admin', get_admin_url().'/images/generic.png'); } function pp_add_init() { $file_dir=get_template_directory_uri(); wp_enqueue_style('thickbox'); wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, THEMEVERSION, "all"); wp_enqueue_style("jqueryui", $file_dir."/css/jqueryui/custom.css", false, THEMEVERSION, "all"); wp_enqueue_style("colorpicker_css", $file_dir."/functions/colorpicker/css/colorpicker.css", false, THEMEVERSION, "all"); wp_enqueue_style("fancybox", $file_dir."/js/fancybox/jquery.fancybox.admin.css", false, THEMEVERSION, "all"); wp_enqueue_style("icheck", $file_dir."/functions/skins/flat/green.css", false, THEMEVERSION, "all"); $pp_font = get_option('pp_font'); if(!empty($pp_font)) { wp_enqueue_style('google_fonts', "http://fonts.googleapis.com/css?family=".$pp_font."&subset=latin,latin-ext,cyrillic,cyrillic-ext", false, "", "all"); } wp_enqueue_script("jquery-ui-core"); wp_enqueue_script("jquery-ui-sortable"); wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_enqueue_script("colorpicker_script", $file_dir."/functions/colorpicker/js/colorpicker.js", false, THEMEVERSION); wp_enqueue_script("eye_script", $file_dir."/functions/colorpicker/js/eye.js", false, THEMEVERSION); wp_enqueue_script("utils_script", $file_dir."/functions/colorpicker/js/utils.js", false, THEMEVERSION); wp_enqueue_script("jquery.icheck.min", $file_dir."/functions/jquery.icheck.min.js", false, THEMEVERSION); wp_enqueue_script("jslider_depend", $file_dir."/functions/jquery.dependClass.js", false, THEMEVERSION); //Fix WPML plugin script conflict $tg_screen = get_current_screen(); if($tg_screen->id == 'toplevel_page_functions' && $_GET["page"] == "functions.php") { wp_enqueue_script("jslider", $file_dir."/functions/jquery.slider-min.js", false, THEMEVERSION); } wp_enqueue_script("fancybox", $file_dir."/js/fancybox/jquery.fancybox.admin.js", false); wp_enqueue_script("tipsy", $file_dir."/functions/jquery.tipsy.js", false); wp_enqueue_script("rm_script", $file_dir."/functions/rm_script.js", false, THEMEVERSION); } add_action('admin_enqueue_scripts', 'pp_add_init' ); function pp_enqueue_front_page_scripts() { //Get all Google Web font CSS global $gg_fonts; $gg_fonts_family = array(); if(is_array($gg_fonts) && !empty($gg_fonts)) { foreach($gg_fonts as $gg_font) { $gg_fonts_family[] = get_option($gg_font.'_value'); } } $gg_fonts_family = array_unique($gg_fonts_family); foreach($gg_fonts_family as $key => $gg_fonts_family_value) { if(!empty($gg_fonts_family_value) && $gg_fonts_family_value != 'Helvetica' && $gg_fonts_family_value != 'Arial') { wp_enqueue_style('google_font'.$key, "http://fonts.googleapis.com/css?family=".urlencode($gg_fonts_family_value).":400,700,400italic&subset=latin,cyrillic-ext,greek-ext,cyrillic", false, "", "all"); } } if(isset($_GET['vegastyle']) && $_GET['vegastyle']==2 && THEMEDEMO) { wp_enqueue_style('google_font_default_2', "http://fonts.googleapis.com/css?family=Oswald:400italic,700italic,400,700&subset=latin,cyrillic-ext,greek-ext,greek,cyrillic,latin-ext,vietnamese", false, "", "all"); } if(isset($_GET['vegastyle']) && $_GET['vegastyle']==3 && THEMEDEMO) { wp_enqueue_style('google_font_default_3', "http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700&subset=latin,cyrillic-ext,greek-ext,greek,cyrillic,latin-ext,vietnamese", false, "", "all"); } //enqueue frontend css files $pp_advance_combine_css = get_option('pp_advance_combine_css'); //If enable animation $pp_animation = get_option('pp_animation'); if(!empty($pp_advance_combine_css)) { if(!file_exists(get_template_directory_uri()."/cache/combined.css")) { $cssmin = new CSSMin(); $css_arr = array( get_template_directory().'/css/screen.css', get_template_directory().'/css/magnific-popup.css', get_template_directory().'/js/flexslider/flexslider.css', get_template_directory().'/js/mediaelement/mediaelementplayer.css', ); if(empty($pp_animation)) { $css_arr[] = get_template_directory().'/css/animation.css'; } $cssmin->addFiles($css_arr); // Set original CSS from all files $cssmin->setOriginalCSS(); $cssmin->compressCSS(); $css = $cssmin->printCompressedCSS(); file_put_contents(get_template_directory()."/cache/combined.css", $css); } wp_enqueue_style("combined_css", get_template_directory_uri()."/cache/combined.css", false, THEMEVERSION); } else { if(empty($pp_animation)) { wp_enqueue_style("animation.css", get_template_directory_uri()."/css/animation.css", false, THEMEVERSION, "all"); } wp_enqueue_style("screen.css", get_template_directory_uri().'/css/screen.css', false, THEMEVERSION, "all"); wp_enqueue_style("mediaelement", get_template_directory_uri()."/js/mediaelement/mediaelementplayer.css", false, THEMEVERSION, "all"); wp_enqueue_style("magnific-popup", get_template_directory_uri()."/css/magnific-popup.css", false, THEMEVERSION, "all"); wp_enqueue_style("flexslider", get_template_directory_uri()."/js/flexslider/flexslider.css", false, THEMEVERSION, "all"); } //Add Font Awesome Support wp_enqueue_style("fontawesome", get_template_directory_uri()."/css/font-awesome.min.css", false, THEMEVERSION, "all"); //Add custom colors and fonts if(isset($_GET['vegastyle']) && THEMEDEMO) { $custom_css_url = get_template_directory_uri()."/templates/custom-css-dynamic.php?vegastyle=".$_GET['vegastyle']; wp_enqueue_style("custom_css", $custom_css_url, false, THEMEVERSION, "all"); } else { wp_enqueue_style("custom_css", get_template_directory_uri()."/templates/custom-css.php", false, THEMEVERSION, "all"); } //Check if enable responsive layout $pp_enable_responsive = get_option('pp_enable_responsive'); if(!empty($pp_enable_responsive)) { wp_enqueue_style('grid', get_template_directory_uri()."/css/grid.css", false, THEMEVERSION, "all"); } //Enqueue javascripts wp_enqueue_script("jquery"); vega_set_map_api(); if(THEMEDEMO) { wp_enqueue_script("jquery.cookie", get_template_directory_uri()."/js/jquery.cookie.js", false, THEMEVERSION); } $js_path = get_template_directory()."/js/"; $js_arr = array( 'jquery.easing.min.js', 'waypoints.min.js', 'jquery.magnific-popup.js', 'jquery.touchwipe.1.1.1.js', 'gmap.js', 'jquery.isotope.js', 'flexslider/jquery.flexslider-min.js', 'jquery.masonry.js', 'mediaelement/mediaelement-and-player.min.js', 'jquery.stellar.js', 'custom_plugins.js', 'custom.js', ); $js = ""; $pp_advance_combine_js = get_option('pp_advance_combine_js'); if(!empty($pp_advance_combine_js)) { if(!file_exists(get_template_directory()."/cache/combined.js")) { foreach($js_arr as $file) { if($file != 'jquery.js' && $file != 'jquery-ui.js') { $js .= JSMin::minify(file_get_contents($js_path.$file)); } } file_put_contents(get_template_directory()."/cache/combined.js", $js); } wp_enqueue_script("combined_js", get_template_directory_uri()."/cache/combined.js", false, THEMEVERSION, true); } else { foreach($js_arr as $file) { if($file != 'jquery.js' && $file != 'jquery-ui.js') { wp_enqueue_script($file, get_template_directory_uri()."/js/".$file, false, THEMEVERSION, true); } } } } add_action( 'wp_enqueue_scripts', 'pp_enqueue_front_page_scripts' ); function pp_admin() { global $themename, $shortname, $options; $i=0; $pp_font_family = get_option('pp_font_family'); if(function_exists( 'wp_enqueue_media' )){ wp_enqueue_media(); } ?> <style> #pp_sample_text { font-family: '<?php echo $pp_font_family; ?>'; } </style> <div id="pp_loading"><span><?php _e( 'Updating...', THEMEDOMAIN ); ?></span></div> <div id="pp_success"><span><?php _e( 'Successfully<br/>Update', THEMEDOMAIN ); ?></span></div> <?php if(isset($_GET['saved']) == 'true') { ?> <script> jQuery('#pp_success').show(); setTimeout(function() { jQuery('#pp_success').fadeOut(); }, 2000); </script> <?php } ?> <form id="pp_form" method="post" enctype="multipart/form-data"> <div class="pp_wrap rm_wrap"> <div class="header_wrap"> <div style="float:left"> <h2><?php _e( 'Theme Setting', THEMEDOMAIN ); ?></h2>(v<?php echo THEMEVERSION; ?>) </div> <div style="float:right;margin:32px 0 0 0"> <!-- input id="save_ppskin" name="save_ppskin" class="button secondary_button" type="submit" value="Save as Skin" / --> <input class="button button-large" type="submit" value="<?php esc_html_e( 'Documentation', THEMEVERSION ); ?>" onclick="window.open('http://themes.themegoods2.com/vega_doc/','_blank')"/> <input id="save_ppsettings" name="save_ppsettings" class="button button-primary button-large" type="submit" value="<?php _e( 'Save All Changes', THEMEDOMAIN ); ?>" /> <br/><br/> <input type="hidden" name="action" value="save" /> <input type="hidden" name="current_tab" id="current_tab" value="#pp_panel_general" /> <input type="hidden" name="pp_save_skin_flg" id="pp_save_skin_flg" value="" /> <input type="hidden" name="pp_save_skin_name" id="pp_save_skin_name" value="" /> </div> <input type="hidden" name="pp_admin_url" id="pp_admin_url" value="<?php echo get_template_directory_uri(); ?>"/> <br style="clear:both"/><br/> <?php $cache_dir = get_template_directory().'/cache'; $data_dir = THEMEUPLOAD; if(!is_writable($cache_dir)) { ?> <div id="message" class="error fade"> <p style="line-height:1.5em"><strong> <?php _e( 'The path ', THEMEDOMAIN ); ?><?php echo $cache_dir; ?><?php _e( ' is not writable, please login with your FTP account and make it writable (chmod 777) otherwise CSS and javascript compression feature won\'t work.', THEMEDOMAIN ); ?> </p></strong> </div> <?php } ?> </div> <div class="pp_wrap"> <div id="pp_panel"> <?php foreach ($options as $value) { /*print '<pre>'; print_r($value); print '</pre>';*/ $active = ''; if($value['type'] == 'section') { if($value['name'] == 'General') { $active = 'nav-tab-active'; } echo '<a id="pp_panel_'.strtolower($value['name']).'_a" href="#pp_panel_'.strtolower($value['name']).'" class="nav-tab '.$active.'"><img src="'.get_template_directory_uri().'/functions/images/icon/'.$value['icon'].'" class="ver_mid"/>'.str_replace('-', ' ', $value['name']).'</a>'; } } ?> </h2> </div> <div class="rm_opts"> <?php // Get Google font list from cache $pp_font_arr = array(); $font_cache_path = get_template_directory().'/cache/gg_fonts.cache'; $file = file_get_contents($font_cache_path, true); $pp_font_arr = unserialize($file); //Get installed Google font (if has) $current_ggfont = get_option('pp_ggfont'); //Get 2 default font $pp_font_arr[] = array( 'font-family' => 'font-family: "Helvetica"', 'font-name' => 'Helvetica', 'css-name' => urlencode('Helvetica'), ); $pp_font_arr[] = array( 'font-family' => 'font-family: "Arial"', 'font-name' => 'Arial', 'css-name' => urlencode('Arial'), ); if(!empty($current_ggfont)) { foreach($current_ggfont as $ggfont) { $pp_font_arr[] = array( 'font-family' => 'font-family: \''.$ggfont.'\'', 'font-name' => $ggfont, 'css-name' => urlencode($ggfont), ); } } //Sort by font name function cmp($a, $b) { return strcmp($a["font-name"], $b["font-name"]); } usort($pp_font_arr, "cmp"); $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; foreach ($options as $value) { switch ( $value['type'] ) { case "open": ?> <?php break; case "close": ?> </div> </div> <?php break; case "title": ?> <br /> <?php break; case 'text': //if sidebar input then not show default value if($value['id'] != SHORTNAME."_sidebar0" && $value['id'] != SHORTNAME."_ggfont0") { $default_val = get_option( $value['id'] ); } else { $default_val = ''; } ?> <div class="rm_input rm_text"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label><br/> <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ($default_val != "") { echo get_option( $value['id']) ; } else { echo $value['std']; } ?>" <?php if(!empty($value['size'])) { echo 'style="width:'.$value['size'].'"'; } ?> /> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> <?php if($value['id'] == SHORTNAME."_sidebar0") { $current_sidebar = get_option(SHORTNAME."_sidebar"); if(!empty($current_sidebar)) { ?> <br class="clear"/><br/> <div class="pp_sortable_wrapper"> <ul id="current_sidebar" class="rm_list"> <?php foreach($current_sidebar as $sidebar) { ?> <li id="<?php echo $sidebar; ?>"><div class="title"><?php echo $sidebar; ?></div><a href="<?php echo $url; ?>" class="sidebar_del" rel="<?php echo $sidebar; ?>">Delete</a><br style="clear:both"/></li> <?php } ?> </ul> </div> <?php } } elseif($value['id'] == SHORTNAME."_ggfont0") { ?> <?php _e( 'Below are fonts that already installed.', THEMEDOMAIN ); ?><br/> <select name="<?php echo SHORTNAME; ?>_sample_ggfont" id="<?php echo SHORTNAME; ?>_sample_ggfont"> <?php foreach ($pp_font_arr as $key => $option) { ?> <option <?php if (get_option( $value['id'] ) == $option['css-name']) { echo 'selected="selected"'; } ?> value="<?php echo $option['css-name']; ?>" data-family="<?php echo $option['font-name']; ?>"><?php echo $option['font-name']; ?></option> <?php } ?> </select> <?php $current_ggfont = get_option(SHORTNAME."_ggfont"); if(!empty($current_ggfont)) { ?> <br class="clear"/><br/> <div class="pp_sortable_wrapper"> <ul id="current_ggfont" class="rm_list"> <?php foreach($current_ggfont as $ggfont) { ?> <li id="<?php echo $ggfont; ?>"><div class="title"><?php echo $ggfont; ?></div><a href="<?php echo $url; ?>" class="ggfont_del" rel="<?php echo $ggfont; ?>">Delete</a><br style="clear:both"/></li> <?php } ?> </ul> </div> <?php } } ?> </div> <?php break; case 'password': ?> <div class="rm_input rm_text"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label><br/> <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_option( $value['id'] ) != "") { echo stripslashes(get_option( $value['id']) ); } else { echo $value['std']; } ?>" <?php if(!empty($value['size'])) { echo 'style="width:'.$value['size'].'"'; } ?> /> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; break; case 'image': case 'music': ?> <div class="rm_input rm_text"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label><br/> <input id="<?php echo $value['id']; ?>" type="text" name="<?php echo $value['id']; ?>" value="<?php echo get_option($value['id']); ?>" style="width:200px" class="upload_text" readonly /> <input id="<?php echo $value['id']; ?>_button" name="<?php echo $value['id']; ?>_button" type="button" value="Upload" class="upload_btn button" rel="<?php echo $value['id']; ?>" style="margin:7px 0 0 5px" /> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> <script> jQuery(document).ready(function() { jQuery('#<?php echo $value['id']; ?>_button').click(function() { var send_attachment_bkp = wp.media.editor.send.attachment; wp.media.editor.send.attachment = function(props, attachment) { formfield = jQuery('#<?php echo $value['id']; ?>').attr('name'); jQuery('#'+formfield).attr('value', attachment.url); jQuery('#pp_form').submit(); wp.media.editor.send.attachment = send_attachment_bkp; } wp.media.editor.open(); }); }); </script> <?php $current_value = get_option( $value['id'] ); if(!is_bool($current_value) && !empty($current_value)) { $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; if($value['type']=='image') { ?> <div id="<?php echo $value['id']; ?>_wrapper" style="width:380px;font-size:11px;"><br/> <img src="<?php echo get_option($value['id']); ?>" style="max-width:500px"/><br/><br/> <a href="<?php echo $url; ?>" class="image_del button" rel="<?php echo $value['id']; ?>"><?php _e( 'Delete', THEMEDOMAIN ); ?></a> </div> <?php } else { ?> <div id="<?php echo $value['id']; ?>_wrapper" style="width:380px;font-size:11px;"> <br/><a href="<?php echo get_option( $value['id'] ); ?>"> <?php _e( 'Listen current music', THEMEDOMAIN ); ?></a> <a href="<?php echo $url; ?>" class="image_del button" rel="<?php echo $value['id']; ?>"><?php _e( 'Delete', THEMEDOMAIN ); ?></a> </div> <?php } } ?> </div> <?php break; case 'jslider': ?> <div class="rm_input rm_text"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label><br/> <div style="float:left;width:290px;margin-top:10px"> <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="text" class="jslider" value="<?php if ( get_option( $value['id'] ) != "") { echo stripslashes(get_option( $value['id']) ); } else { echo $value['std']; } ?>" <?php if(!empty($value['size'])) { echo 'style="width:'.$value['size'].'"'; } ?> /> </div> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> <script>jQuery("#<?php echo $value['id']; ?>").slider({ from: <?php echo $value['from']; ?>, to: <?php echo $value['to']; ?>, step: <?php echo $value['step']; ?>, smooth: true, skin: "round_plastic" });</script> </div> <?php break; case 'colorpicker': ?> <div class="rm_input rm_text"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label><br/> <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="text" value="<?php if ( get_option( $value['id'] ) != "" ) { echo stripslashes(get_option( $value['id']) ); } else { echo $value['std']; } ?>" <?php if(!empty($value['size'])) { echo 'style="width:'.$value['size'].'"'; } ?> class="color_picker" readonly/> <div id="<?php echo $value['id']; ?>_bg" class="colorpicker_bg" onclick="jQuery('#<?php echo $value['id']; ?>').click()" style="background:<?php if (get_option( $value['id'] ) != "") { echo stripslashes(get_option( $value['id']) ); } else { echo $value['std']; } ?> url(<?php echo get_template_directory_uri(); ?>/functions/images/trigger.png) center no-repeat;"> </div> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case 'textarea': ?> <div class="rm_input rm_textarea"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label><br/> <textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_option( $value['id'] ) != "") { echo stripslashes(get_option( $value['id']) ); } else { echo $value['std']; } ?></textarea> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case 'select': ?> <div class="rm_input rm_select"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label><br/> <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"> <?php foreach ($value['options'] as $key => $option) { ?> <option <?php if (get_option( $value['id'] ) == $key) { echo 'selected="selected"'; } ?> value="<?php echo $key; ?>"><?php echo $option; ?></option> <?php } ?> </select> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case 'font': ?> <div class="rm_input rm_font"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label><br/> <div id="<?php echo $value['id']; ?>_wrapper" style="float:left;font-size:11px;"> <select class="pp_font" data-sample="<?php echo $value['id']; ?>_sample" data-value="<?php echo $value['id']; ?>_value" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"> <option value="" data-family="">---- Theme Default Font ----</option> <?php foreach ($pp_font_arr as $key => $option) { ?> <option <?php if (get_option( $value['id'] ) == $option['css-name']) { echo 'selected="selected"'; } ?> value="<?php echo $option['css-name']; ?>" data-family="<?php echo $option['font-name']; ?>"><?php echo $option['font-name']; ?></option> <?php } ?> </select> <input type="hidden" id="<?php echo $value['id']; ?>_value" name="<?php echo $value['id']; ?>_value" value="<?php echo get_option( $value['id'].'_value' ); ?>"/> <br/><br/><div id="<?php echo $value['id']; ?>_sample" class="pp_sample_text">Sample Text</div> </div> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case 'radio': ?> <div class="rm_input rm_select"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label><br/> <div style="margin-top:5px;float:left;width:300px"> <?php foreach ($value['options'] as $key => $option) { ?> <div style="float:left;margin:0 20px 20px 0"> <input style="float:left;" id="<?php echo $value['id']; ?>" name="<?php echo $value['id']; ?>" type="radio" <?php if (get_option( $value['id'] ) == $key) { echo 'checked="checked"'; } ?> value="<?php echo $key; ?>"/><?php echo $option; ?> </div> <?php } ?> </div> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case 'sortable': ?> <div class="rm_input rm_select"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label><br/> <div style="float:left;width:100%;"> <?php $sortable_array = unserialize(get_option( $value['id'] )); $current = 1; if(!empty($value['options'])) { ?> <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" class="pp_sortable_select"> <?php foreach ($value['options'] as $key => $option) { if($key > 0) { ?> <option value="<?php echo $key; ?>" data-rel="<?php echo $value['id']; ?>_sort" title="<?php echo html_entity_decode($option); ?>"><?php echo html_entity_decode($option); ?></option> <?php } if($current>1 && ($current-1)%3 == 0) { ?> <br style="clear:both"/> <?php } $current++; } ?> </select> <a class="button pp_sortable_button" data-rel="<?php echo $value['id']; ?>" class="button" style="margin-top:10px;display:inline-block"><?php _e( 'Add', THEMEDOMAIN ); ?></a> <?php } ?> <br style="clear:both"/><br/> <div class="pp_sortable_wrapper"> <ul id="<?php echo $value['id']; ?>_sort" class="pp_sortable" rel="<?php echo $value['id']; ?>_sort_data"> <?php $sortable_data_array = unserialize(get_option( $value['id'].'_sort_data' )); if(!empty($sortable_data_array)) { foreach($sortable_data_array as $key => $sortable_data_item) { if(!empty($sortable_data_item)) { ?> <li id="<?php echo $sortable_data_item; ?>_sort" class="ui-state-default"><div class="title"><?php echo $value['options'][$sortable_data_item]; ?></div><a data-rel="<?php echo $value['id']; ?>_sort" href="javascript:;" class="remove">x</a><br style="clear:both"/></li> <?php } } } ?> </ul> </div> </div> <input type="hidden" id="<?php echo $value['id']; ?>_sort_data" name="<?php echo $value['id']; ?>_sort_data" value="" style="width:100%"/> <br style="clear:both"/><br/> <div class="clearfix"></div> </div> <?php break; case "checkbox": ?> <?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?> <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> /> <div class="rm_input rm_checkbox"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case "iphone_checkboxes": ?> <div class="rm_input rm_checkbox"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label> <?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?> <input type="checkbox" class="iphone_checkboxes" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> /> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case "html": ?> <div class="rm_input rm_checkbox"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label><br/> <?php echo $value['html']; ?> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case "section": $i++; ?> <div id="pp_panel_<?php echo strtolower($value['name']); ?>" class="rm_section"> <div class="rm_title"> <h3><img src="<?php echo get_template_directory_uri(); ?>/functions/images/trans.png" class="inactive" alt=""><?php echo $value['name']; ?></h3> <span class="submit"><input class="button-primary" name="save<?php echo $i; ?>" type="submit" value="<?php _e( 'Save changes', THEMEDOMAIN ); ?>" /> </span> <div class="clearfix"></div> </div> <div class="rm_options"><?php break; } } ?> <div class="clearfix"></div> </form> </div> <?php } add_action('admin_menu', 'pp_add_admin'); /** * Setup all theme's modules **/ //Setup content builder include (get_template_directory() . "/modules/content_builder.php"); // Setup shortcode generator modules include (get_template_directory() . "/modules/shortcode_generator.php"); // Setup Twitter API include (get_template_directory() . "/modules/twitteroauth.php"); //Add arrow to parent menu item class Arrow_Walker_Nav_Menu extends Walker_Nav_Menu { function display_element($element, &$children_elements, $max_depth, $depth=0, $args, &$output) { $id_field = $this->db_fields['id']; if (!empty($children_elements[$element->$id_field])) { $element->classes[] = 'arrow'; //enter any classname you like here! } Walker_Nav_Menu::display_element($element, $children_elements, $max_depth, $depth, $args, $output); } } add_filter( 'comment_form_default_fields', 'wpse_62742_comment_placeholders' ); /** * Change default fields, add placeholder and change type attributes. * * @param array $fields * @return array */ function wpse_62742_comment_placeholders( $fields ) { $fields['author'] = str_replace('<input', '<input placeholder="'. __('Name', THEMEDOMAIN). '"',$fields['author']); $fields['email'] = str_replace('<input id="email" name="email" type="text"', '<input type="email" placeholder="'.__('Email', THEMEDOMAIN).'" id="email" name="email"',$fields['email']); $fields['url'] = str_replace('<input id="url" name="url" type="text"', '<input placeholder="'.__('Website', THEMEDOMAIN).'" id="url" name="url" type="url"',$fields['url']); return $fields; } // A callback function to add a custom field to our "gallery categories" taxonomy function gallerycat_taxonomy_custom_fields($tag) { wp_enqueue_media(); // Check for existing taxonomy meta for the term you're editing $t_id = $tag->term_id; // Get the ID of the term you're editing $term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check ?> <tr class="form-field"> <th scope="row" valign="top"> <label for="gallerycat_ft_img"><?php _e('Category Featured Image', THEMEDOMAIN); ?></label> </th> <td> <input type="text" name="gallerycat_ft_img" id="gallerycat_ft_img" size="25" style="width:60%;" value="<?php echo $term_meta['gallerycat_ft_img'] ? $term_meta['gallerycat_ft_img'] : ''; ?>"> <input id="gallerycat_ft_img_button" name="gallerycat_ft_img_button" type="button" value="Upload" class="upload_btn button" rel="term_meta[gallerycat_ft_img]" style="margin:0 0 0 5px" /> <br /> <span class="description"><?php _e('Category Featured Image which displays as header background image on this category page', THEMEDOMAIN); ?></span> <?php if(!empty($term_meta['gallerycat_ft_img'])) { ?> <div id="gallerycat_ft_img_wrapper"> <img src="<?php echo $term_meta['gallerycat_ft_img']; ?>" alt=""/> </div> <?php } else { ?> <div id="gallerycat_ft_img_wrapper"></div> <?php } ?> <script> jQuery(document).ready(function() { jQuery('#gallerycat_ft_img_button').click(function() { var send_attachment_bkp = wp.media.editor.send.attachment; wp.media.editor.send.attachment = function(props, attachment) { jQuery('#gallerycat_ft_img').val(attachment.url); jQuery('#gallerycat_ft_img_wrapper').html('<img src="'+attachment.url+'" alt=""/>'); wp.media.editor.send.attachment = send_attachment_bkp; } wp.media.editor.open(); }); }); </script> </td> </tr> <?php } // A callback function to save our extra taxonomy field(s) function save_taxonomy_custom_fields( $term_id ) { if ( isset( $_POST['gallerycat_ft_img'] ) ) { $t_id = $term_id; $term_meta = get_option( "taxonomy_term_$t_id" ); if ( isset( $_POST['gallerycat_ft_img'] ) ){ $term_meta['gallerycat_ft_img'] = $_POST['gallerycat_ft_img']; } //save the option array update_option( "taxonomy_term_$t_id", $term_meta ); } } // Add the fields to the "portfolio categories" taxonomy, using our callback function add_action( 'gallerycat_edit_form_fields', 'gallerycat_taxonomy_custom_fields', 10, 2 ); // Save the changes made on the "presenters" taxonomy, using our callback function add_action( 'edited_gallerycat', 'save_taxonomy_custom_fields', 10, 2 ); // A callback function to add a custom field to our "gallery categories" taxonomy function portfoliosets_taxonomy_custom_fields($tag) { wp_enqueue_media(); // Check for existing taxonomy meta for the term you're editing $t_id = $tag->term_id; // Get the ID of the term you're editing $term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check ?> <tr class="form-field"> <th scope="row" valign="top"> <label for="gallerycat_ft_img"><?php _e('Category Featured Image', THEMEDOMAIN); ?></label> </th> <td> <input type="text" name="portfoliosets_ft_img" id="portfoliosets_ft_img" size="25" style="width:60%;" value="<?php echo $term_meta['portfoliosets_ft_img'] ? $term_meta['portfoliosets_ft_img'] : ''; ?>"> <input id="portfoliosets_ft_img_button" name="portfoliosets_ft_img_button" type="button" value="Upload" class="upload_btn button" rel="term_meta[portfoliosets_ft_img]" style="margin:0 0 0 5px" /> <br /> <span class="description"><?php _e('Category Featured Image which displays as header background image on this category page', THEMEDOMAIN); ?></span> <?php if(!empty($term_meta['portfoliosets_ft_img'])) { ?> <div id="gallerycat_ft_img_wrapper"> <img src="<?php echo $term_meta['portfoliosets_ft_img']; ?>" alt=""/> </div> <?php } else { ?> <div id="gallerycat_ft_img_wrapper"></div> <?php } ?> <script> jQuery(document).ready(function() { jQuery('#portfoliosets_ft_img_button').click(function() { var send_attachment_bkp = wp.media.editor.send.attachment; wp.media.editor.send.attachment = function(props, attachment) { jQuery('#portfoliosets_ft_img').val(attachment.url); jQuery('#gallerycat_ft_img_wrapper').html('<img src="'+attachment.url+'" alt=""/>'); wp.media.editor.send.attachment = send_attachment_bkp; } wp.media.editor.open(); }); }); </script> </td> </tr> <?php } // A callback function to save our extra taxonomy field(s) function save_portfoliosets_taxonomy_custom_fields( $term_id ) { if ( isset( $_POST['portfoliosets_ft_img'] ) ) { $t_id = $term_id; $term_meta = get_option( "taxonomy_term_$t_id" ); if ( isset( $_POST['portfoliosets_ft_img'] ) ){ $term_meta['portfoliosets_ft_img'] = $_POST['portfoliosets_ft_img']; } //save the option array update_option( "taxonomy_term_$t_id", $term_meta ); } } // Add the fields to the "presenters" taxonomy, using our callback function add_action( 'portfoliosets_edit_form_fields', 'portfoliosets_taxonomy_custom_fields', 10, 2 ); // Save the changes made on the "presenters" taxonomy, using our callback function add_action( 'edited_portfoliosets', 'save_portfoliosets_taxonomy_custom_fields', 10, 2 ); //Make widget support shortcode add_filter('widget_text', 'do_shortcode'); if(THEMEDEMO) { function add_my_query_var( $link ) { $arr_params = array(); if(isset($_GET['vegastyle'])) { $arr_params['vegastyle'] = $_GET['vegastyle']; } else { $arr_params['vegastyle'] = 1; } $link = add_query_arg( $arr_params, $link ); return $link; } add_filter('category_link','add_my_query_var'); add_filter('page_link','add_my_query_var'); add_filter('post_link','add_my_query_var'); add_filter('term_link','add_my_query_var'); add_filter('tag_link','add_my_query_var'); add_filter('category_link','add_my_query_var'); add_filter('post_type_link','add_my_query_var'); add_filter('attachment_link','add_my_query_var'); add_filter('year_link','add_my_query_var'); add_filter('month_link','add_my_query_var'); add_filter('day_link','add_my_query_var'); add_filter('search_link','add_my_query_var'); add_filter('previous_post_link','add_my_query_var'); add_filter('next_post_link','add_my_query_var'); add_filter('home_url','add_my_query_var'); } if (isset($_GET['activated']) && $_GET['activated']){ global $wpdb; //Run default settings include_once(get_template_directory() . "/default_settings.php"); wp_redirect(admin_url("themes.php?page=functions.php&activate=true#pp_panel_demo-import")); } ?>
SAVE
CANCEL