Beispiel #1
0
function theme_version_check()
{
    $last_version = (int) wpv_get_option('theme_installed_version');
    if (empty($last_version)) {
        $last_version = 1;
    }
    if ($last_version < (int) WpvFramework::get_version()) {
        wpv_update_option('theme_installed_version', (int) WpvFramework::get_version());
    }
}
 /**
  * Imports a skin
  */
 public function load_skin()
 {
     $name = $_POST['name'];
     $file = $_POST['file'];
     wpv_update_option('last-active-skin', $name);
     $data = json_decode(file_get_contents(WPV_SAVED_OPTIONS . $file));
     foreach ($data as $id => $val) {
         if (is_string($val)) {
             $val = str_replace('{WPV_SAMPLES_URI}', WPV_SAMPLES_URI, $val);
         }
         wpv_update_option($id, $val);
     }
     wpv_finalize_custom_css();
     echo json_encode(array('data' => $data, 'text' => '<span class="success">' . __('The skin has been imported successfully. Have fun!', 'church-event') . '</span>'));
     exit;
 }
/**
 * Called after the CSS cache is generated
 */
function wpv_finalize_custom_css()
{
    global $used_google_fonts, $used_local_fonts, $wpv_mocked;
    $font_imports = '';
    $font_imports_urls = array();
    $pages = array('general', 'layout', 'styles', 'import');
    foreach ($pages as $page_str) {
        $tabs = (include WPV_THEME_OPTIONS . $page_str . '/list.php');
        foreach ($tabs as $tab) {
            $tab_contents = (include WPV_THEME_OPTIONS . $page_str . "/{$tab}.php");
            foreach ($tab_contents as $opt) {
                if (isset($opt['type']) && $opt['type'] == 'font') {
                    wpv_use_font($opt['id']);
                }
            }
        }
    }
    if (is_array($used_google_fonts) && count($used_google_fonts)) {
        $param = array();
        foreach ($used_google_fonts as $font => $weights) {
            $weights[] = 'bold';
            // always include a bold version, if available
            $weights = array_unique($weights);
            $param[] = urlencode($font) . ':' . implode(',', array_unique($weights));
        }
        $param = implode('|', $param);
        $font_imports .= "@import url('//fonts.googleapis.com/css?family=" . $param . "&subset=" . wpv_get_option('google-fonts-subsets') . "');\n";
        $font_imports_urls['gfonts'] = "//fonts.googleapis.com/css?family=" . $param . "&subset=" . wpv_get_option('google-fonts-subsets');
    }
    if (is_array($used_local_fonts) && count($used_local_fonts)) {
        foreach ($used_local_fonts as $font) {
            $font_imports .= "@import url('" . WPV_FONTS_URI . "{$font}/stylesheet.css');\n";
            $font_imports_urls[$font] = WPV_FONTS_URI . "{$font}/stylesheet.css";
        }
    }
    ob_start();
    WpvLess::compile();
    if (!isset($wpv_mocked)) {
        wpv_update_option('external-fonts', $font_imports_urls);
        return ob_get_clean();
    } else {
        return array('styles' => ob_get_clean(), 'imports' => $font_imports);
    }
}
function wpv_save_options_callback()
{
    $page_str = str_replace('wpv_', '', $_POST['page']);
    $options = array();
    $tabs = (include WPV_THEME_OPTIONS . $page_str . '/list.php');
    foreach ($tabs as $tab) {
        $tab_contents = (include WPV_THEME_OPTIONS . $page_str . "/{$tab}.php");
        $options = array_merge($options, $tab_contents);
    }
    $status = '';
    if (!isset($_POST['cacheonly'])) {
        $status = wpv_save_config($options);
    } else {
        $status = wpv_finalize_custom_css();
    }
    wpv_update_option('css-cache-timestamp', time());
    do_action('wpv_after_save_theme_options');
    echo $status;
    exit;
}
 /**
  * Initialize the theme admin
  */
 public function __construct()
 {
     $this->option_pages = array('general' => array(__('VamTam | General Settings', 'church-event'), __('General Settings', 'church-event')), 'layout' => array(__('VamTam | Layout', 'church-event'), __('Layout', 'church-event')), 'styles' => array(__('VamTam | Styles', 'church-event'), __('Styles', 'church-event')), 'import' => array(__('VamTam | Quick Import', 'church-event'), __('Quick Import', 'church-event')), 'help' => array(__('VamTam | help', 'church-event'), __('Help', 'church-event')));
     add_action('admin_init', array('WpvUpdateNotice', 'check'));
     add_action('admin_footer', array(__CLASS__, 'icons_selector'));
     add_action('admin_menu', array(&$this, 'load_menus'));
     add_action('menu_order', array(&$this, 'reorder_menus'));
     add_action('add_meta_boxes', array(&$this, 'load_metaboxes'));
     add_action('save_post', array(&$this, 'load_metaboxes'));
     add_action('sidebar_admin_setup', array(&$this, 'sidebar_admin_setup'));
     add_action('wp_ajax_wpv-delete-widget-area', array('WpvSidebarInterface', 'delete_widget_area'));
     add_filter('admin_notices', array(__CLASS__, 'update_warning'));
     require_once WPV_ADMIN_METABOXES . 'shortcode.php';
     $this->load_functions();
     new WpvSkinManagement();
     new WpvIconsHelper();
     new WpvFontsHelper();
     require_once WPV_ADMIN_HELPERS . 'updates/version-checker.php';
     if (!wpv_get_option(THEME_SLUG . '_vamtam_theme_activated', false)) {
         wpv_update_option(THEME_SLUG . '_vamtam_theme_activated', true);
         delete_option('default_comment_status');
     }
 }
 private static function set_sidebars_list($sidebars)
 {
     wpv_update_option('custom-sidebars', implode(',', $sidebars));
 }
 public function check_version()
 {
     $local_version = WpvFramework::get_version();
     $key = THEME_SLUG . '_' . $local_version;
     $last_license_key = wpv_get_option('envato-license-key-old');
     $current_license_key = wpv_get_option('envato-license-key');
     $system_status_opt_out_old = wpv_get_option('system-status-opt-out-old');
     $system_status_opt_out = wpv_get_option('system-status-opt-out');
     if ($last_license_key !== $current_license_key || $system_status_opt_out_old !== $system_status_opt_out || false === get_transient($key)) {
         global $wp_version;
         $data = array('user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() . '; ', 'blocking' => false, 'body' => array('theme_version' => $local_version, 'php_version' => phpversion(), 'server' => $_SERVER['SERVER_SOFTWARE'], 'theme_name' => THEME_NAME, 'license_key' => $current_license_key, 'active_plugins' => self::active_plugins(), 'system_status' => self::system_status()));
         if ($last_license_key !== $current_license_key) {
             wpv_update_option('envato-license-key-old', $current_license_key);
         }
         if ($system_status_opt_out_old !== $system_status_opt_out) {
             wpv_update_option('system-status-opt-out-old', $system_status_opt_out_old);
         }
         wp_remote_post($this->remote, $data);
         set_transient($key, true, $this->interval);
         // cache
     }
 }
 /**
  * dissmiss the notice once the theme options have been saved
  */
 public static function dismiss_notice()
 {
     update_option(THEME_SLUG . self::$last_version_key, WpvFramework::get_version());
     wpv_update_option('theme-update-notice-dismissed', true);
 }
 /**
  * Registers post types
  */
 private function load_types()
 {
     // portfolios
     register_post_type('portfolio', array('labels' => array('name' => _x('Portfolios', 'post type general name', 'church-event'), 'singular_name' => _x('Portfolio', 'post type singular name', 'church-event'), 'add_new' => _x('Add New', 'portfolio', 'church-event'), 'add_new_item' => __('Add New Portfolio', 'church-event'), 'edit_item' => __('Edit Portfolio', 'church-event'), 'new_item' => __('New Portfolio', 'church-event'), 'view_item' => __('View Portfolio', 'church-event'), 'search_items' => __('Search Portfolios', 'church-event'), 'not_found' => __('No portfolios found', 'church-event'), 'not_found_in_trash' => __('No portfolios found in Trash', 'church-event'), 'parent_item_colon' => ''), 'singular_label' => __('portfolio', 'church-event'), 'public' => true, 'exclude_from_search' => false, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('with_front' => false, 'slug' => wpv_get_option('portfolio-slug')), 'query_var' => false, 'menu_position' => '55.4', 'supports' => array('comments', 'editor', 'excerpt', 'page-attributes', 'thumbnail', 'title')));
     register_taxonomy('portfolio_category', 'portfolio', array('hierarchical' => true, 'labels' => array('name' => _x('Portfolio Categories', 'taxonomy general name', 'church-event'), 'singular_name' => _x('Portfolio Category', 'taxonomy singular name', 'church-event'), 'search_items' => __('Search Portfolio Categories', 'church-event'), 'popular_items' => __('Popular Portfolio Categories', 'church-event'), 'all_items' => __('All Portfolio Categories', 'church-event'), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __('Edit Portfolio Category', 'church-event'), 'update_item' => __('Update Portfolio Category', 'church-event'), 'add_new_item' => __('Add New Portfolio Category', 'church-event'), 'new_item_name' => __('New Portfolio Category Name', 'church-event'), 'separate_items_with_commas' => __('Separate Portfolio category with commas', 'church-event'), 'add_or_remove_items' => __('Add or remove portfolio category', 'church-event'), 'choose_from_most_used' => __('Choose from the most used portfolio category', 'church-event')), 'show_ui' => true, 'query_var' => true, 'rewrite' => false));
     register_post_type('testimonials', array('labels' => array('name' => _x('Testimonials', 'post type general name', 'church-event'), 'singular_name' => _x('Testimonial', 'post type singular name', 'church-event'), 'add_new' => _x('Add New', 'testimonials', 'church-event'), 'add_new_item' => __('Add New Testimonial', 'church-event'), 'edit_item' => __('Edit Testimonial', 'church-event'), 'new_item' => __('New Testimonial', 'church-event'), 'view_item' => __('View Testimonial', 'church-event'), 'search_items' => __('Search Testimonials', 'church-event'), 'not_found' => __('No testimonials found', 'church-event'), 'not_found_in_trash' => __('No testimonials found in Trash', 'church-event'), 'parent_item_colon' => ''), 'singular_label' => __('testimonial', 'church-event'), 'public' => true, 'publicly_queryable' => false, 'exclude_from_search' => true, 'show_ui' => true, 'show_in_nav_menus' => false, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => '55.3', 'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments', 'page-attributes')));
     register_taxonomy('testimonials_category', 'testimonials', array('hierarchical' => true, 'labels' => array('name' => _x('Testimonials Category', 'taxonomy general name', 'church-event'), 'singular_name' => _x('Testimonial Category', 'taxonomy singular name', 'church-event'), 'search_items' => __('Search Categories', 'church-event'), 'popular_items' => __('Popular Categories', 'church-event'), 'all_items' => __('All Categories', 'church-event'), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __('Edit Testimonials Category', 'church-event'), 'update_item' => __('Update Testimonials Category', 'church-event'), 'add_new_item' => __('Add New Testimonials Category', 'church-event'), 'new_item_name' => __('New Testimonials Category Name', 'church-event'), 'separate_items_with_commas' => __('Separate Testimonials category with commas', 'church-event'), 'add_or_remove_items' => __('Add or remove testimonials category', 'church-event'), 'choose_from_most_used' => __('Choose from the most used testimonials category', 'church-event')), 'show_ui' => true, 'query_var' => false, 'rewrite' => false));
     if (wpv_get_option('portfolio-slug') !== wpv_get_option('previous-portfolio-slug')) {
         flush_rewrite_rules();
         wpv_update_option('previous-portfolio-slug', wpv_get_option('portfolio-slug'));
     }
 }
Beispiel #10
0
 /**
  * Registered callback function for the WordPress Importer
  *
  * Manages the three separate stages of the WXR import process
  */
 function dispatch()
 {
     $this->header();
     $step = empty($_GET['step']) ? 0 : $_GET['step'];
     switch ($step) {
         case 0:
             $this->greet();
             break;
         case 1:
             check_admin_referer('import-upload');
             if ($this->handle_upload()) {
                 $this->import_options();
             }
             break;
         case 2:
             if (isset($_GET['file'])) {
                 check_admin_referer('wpv-import');
                 $file = $_GET['file'];
                 $this->fetch_attachments = $this->allow_fetch_attachments();
                 $this->one_click = true;
                 wpv_update_option('used-one-click-import', true);
             } else {
                 check_admin_referer('import-wordpress');
                 $this->fetch_attachments = !empty($_POST['fetch_attachments']) && $this->allow_fetch_attachments();
                 $this->id = (int) $_POST['import_id'];
                 $file = get_attached_file($this->id);
                 $this->one_click = false;
             }
             set_time_limit(0);
             $this->import($file);
             break;
     }
     $this->footer();
 }
function wpv_save_option_by_id($id, $type)
{
    if (isset($_POST[$id])) {
        if ($type == 'multiselect') {
            if (empty($_POST[$id])) {
                wpv_update_option($id, array());
            } else {
                wpv_update_option($id, array_unique($_POST[$id]));
            }
        } else {
            wpv_update_option($id, $_POST[$id]);
        }
    } elseif ($type == 'font' || $type == 'background') {
        $suboptions = array('font' => array('size', 'lheight', 'face', 'weight', 'color'), 'background' => array('image', 'opacity', 'color', 'position', 'attachment', 'repeat', 'size'));
        foreach ($suboptions[$type] as $opt) {
            $name = $id . '-' . $opt;
            if (isset($_POST[$name])) {
                wpv_update_option($name, $_POST[$name]);
            } else {
                wpv_delete_option($name);
            }
            if (isset($_POST['doreset'])) {
                wpv_delete_option($name);
            }
        }
    } elseif ($type === 'checkbox') {
        wpv_update_option($id, 'false');
    } else {
        wpv_update_option($id, false);
    }
    if (isset($_POST['doreset'])) {
        wpv_delete_option($id);
        return false;
    }
}