Example #1
0
/**
 * Get current settings page tab
 */
function quadro_get_current_tab()
{
    $page = 'quadro-settings';
    if (isset($_GET['page']) && 'quadro-reference' == $_GET['page']) {
        $page = 'quadro-reference';
    }
    if (isset($_GET['tab'])) {
        $current = $_GET['tab'];
    } else {
        $quadro_options = quadro_get_options();
        $current = 'general';
    }
    return apply_filters('quadro_get_current_tab', $current);
}
Example #2
0
<?php

/*******
  Original Plugin & API by Kaspars Dambis (kaspars@konstruktors.com)
  Modified by Jeremy Clark http://clark-technet.com
  Modified by QuadroIdeas http://quadroideas.com
*******/
// TEMP: Enable update check on every request. Normally we don't need this! This is for testing only!
// set_site_transient('update_themes', null);
// NOTE: All variables and functions will need to be prefixed properly to allow multiple plugins to be updated
$api_url = 'http://quadroideas.com/quadroupdates';
global $quadro_options;
$quadro_options = quadro_get_options();
/***********************Parent Theme**************/
$theme_data = wp_get_theme(get_option('template'));
$theme_version = $theme_data->Version;
$theme_base = get_option('template');
/**************************************************/
//Uncomment below to find the theme slug that will need to be setup on the api server
// var_dump($theme_base);
function qi_theme_update_check($checked_data)
{
    global $wp_version, $theme_version, $theme_base, $api_url, $quadro_options;
    $request = array('slug' => $theme_base, 'version' => $theme_version, 'username' => $quadro_options['quadro_username'], 'userpass' => $quadro_options['quadro_userpass']);
    // Start checking for an update
    $send_for_check = array('body' => array('action' => 'theme_update', 'request' => serialize($request), 'api-key' => md5(esc_url(home_url('/')))), 'user-agent' => 'WordPress/' . $wp_version . '; ' . esc_url(home_url('/')));
    $raw_response = wp_remote_post($api_url, $send_for_check);
    if (!is_wp_error($raw_response) && $raw_response['response']['code'] == 200) {
        $response = unserialize($raw_response['body']);
    }
    // Feed the update data into WP updater
Example #3
0
/**
 * Register widgetized areas.
 */
function quadro_widgets_init()
{
    // Retrieve Theme Options
    $quadro_options = quadro_get_options();
    register_sidebar(array('name' => esc_html__('Sidebar', 'quadro'), 'id' => 'main-sidebar', 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h1 class="widget-title">', 'after_title' => '</h1>'));
    // Create Header Widgetized Area
    if ($quadro_options['widgetized_header_display'] == 'show') {
        if ($quadro_options['widgt_header_layout'] == 'widg-layout1') {
            $i = 4;
        } else {
            if ($quadro_options['widgt_header_layout'] == 'widg-layout2' || $quadro_options['widgt_header_layout'] == 'widg-layout3' || $quadro_options['widgt_header_layout'] == 'widg-layout4') {
                $i = 3;
            } else {
                if ($quadro_options['widgt_header_layout'] === 'widg-layout5') {
                    $i = 2;
                } else {
                    if ($quadro_options['widgt_header_layout'] == 'widg-layout6') {
                        $i = 1;
                    }
                }
            }
        }
        for ($j = 1; $j <= $i; $j++) {
            register_sidebar(array('name' => 'Header Column ' . $j, 'id' => 'header-sidebar' . $j, 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h1 class="widget-title">', 'after_title' => '</h1>'));
        }
        // end for
    }
    // Create Footer Widgets Area
    if ($quadro_options['widgetized_footer_layout'] == 'widg-layout1') {
        $i = 4;
    } else {
        if ($quadro_options['widgetized_footer_layout'] == 'widg-layout2' || $quadro_options['widgetized_footer_layout'] == 'widg-layout3' || $quadro_options['widgetized_footer_layout'] == 'widg-layout4') {
            $i = 3;
        } else {
            if ($quadro_options['widgetized_footer_layout'] === 'widg-layout5') {
                $i = 2;
            } else {
                if ($quadro_options['widgetized_footer_layout'] == 'widg-layout6') {
                    $i = 1;
                }
            }
        }
    }
    for ($j = 1; $j <= $i; $j++) {
        register_sidebar(array('name' => 'Footer Column ' . $j, 'id' => 'footer-sidebar' . $j, 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h1 class="widget-title">', 'after_title' => '</h1>'));
    }
    // end for
    // Create User Added Sidebars
    if (is_array($quadro_options['quadro_sidebars'])) {
        foreach ($quadro_options['quadro_sidebars'] as $user_sidebar) {
            // Skip iteration if there's no name for this sidebar
            if ($user_sidebar['name'] == '') {
                continue;
            }
            register_sidebar(array('name' => esc_attr($user_sidebar['name']), 'id' => esc_attr($user_sidebar['slug']), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h1 class="widget-title">', 'after_title' => '</h1>'));
        }
        // end for
    }
}
Example #4
0
/**
 * Ajax Theme Options Functions
 * Adapted from: https://github.com/syamilmj/Options-Framework
 */
function quadro_ajax_callback()
{
    $nonce = $_POST['security'];
    if (!wp_verify_nonce($nonce, 'quadro_ajax_nonce')) {
        die('-1');
    }
    // Get Theme Options
    $current_options = quadro_get_options();
    $call_type = $_POST['type'];
    if ($call_type == 'backup_options') {
        $backup = $current_options;
        $backup['backup_log'] = date("D, j M Y G:i:s");
        global $quadro_options_group;
        update_option($quadro_options_group . '_backup', $backup);
        die('1');
    } elseif ($call_type == 'restore_options') {
        global $quadro_options_group;
        $data = get_option($quadro_options_group . '_backup');
        // Set value to let the validation callback know
        // it is alright to go through all the options.
        $data['restore_next'] = true;
        update_option($quadro_options_group, $data);
        die('1');
    } elseif ($call_type == 'import_options') {
        $data = $_POST['data'];
        $data = unserialize(urldecode($data));
        // Set value to let the validation callback know
        // it is alright to go through all the options.
        $data['restore_next'] = true;
        global $quadro_options_group;
        update_option($quadro_options_group, $data);
        die('1');
    } elseif ($call_type == 'dcontent_import') {
        // Include Dummy Content Importer functions
        require get_template_directory() . '/inc/qi-framework/dcontent_importer.php';
        // Run Dummy Content Import functions
        quadro_dcontent_import();
        die('1');
    } elseif ($call_type == 'typekit_activate') {
        $check_url = 'http://quadroideas.com/users-api-typekit';
        $send_for_check = array('body' => array('item_slug' => get_option('template'), 'username' => $current_options['quadro_username'], 'userpass' => $current_options['quadro_userpass'], 'userlicense' => $current_options['quadro_userlicense']));
        $raw_response = wp_remote_post($check_url, $send_for_check);
        if (!is_wp_error($raw_response)) {
            // unserialize response
            $raw_response['body'] = json_decode($raw_response['body']);
            // Print the proper response now
            if ($raw_response['body']->error_msg == '') {
                // populate Typekit options
                $current_options['typekit_kit_id'] = wp_kses($raw_response['body']->typekit_kit_id, '');
                $current_options['typekit_kit_headings_family'] = wp_kses($raw_response['body']->headings_font, '');
                $current_options['typekit_kit_body_family'] = wp_kses($raw_response['body']->body_font, '');
                // Set value to let the validation callback know
                // it is alright to go through all the options.
                $current_options['restore_next'] = true;
                // save options
                global $quadro_options_group;
                update_option($quadro_options_group, $current_options);
                // print success message
                echo esc_html__('Typekit kit activated on theme! Please refresh this page before saving other options. For added beauty, we recommend setting the body size on 20px.', 'quadro');
            } else {
                // print error message
                echo $raw_response['body']->error_msg;
            }
        } else {
            // If there was a WP error, print it
            echo $raw_response->get_error_message();
        }
        die;
    } elseif ($call_type == 'user_check') {
        $check_url = 'http://quadroideas.com/users-api-check';
        $send_for_check = array('body' => array('item_slug' => get_option('template'), 'username' => esc_attr($_POST['username']), 'userpass' => esc_attr($_POST['userpass']), 'license' => esc_attr($_POST['license'])));
        $raw_response = wp_remote_post($check_url, $send_for_check);
        if (!is_wp_error($raw_response) && $raw_response['response']['code'] == 200) {
            // Print the proper response now
            if ($raw_response['body'] == 'ok') {
                echo esc_html__('You theme was sucesfully verified.', 'quadro');
            } else {
                echo $raw_response['body'];
            }
        } else {
            // If there was a WP error, print it
            echo $raw_response->get_error_message();
        }
        die;
    } elseif ($call_type == 'portfolio_transients_delete') {
        global $wpdb;
        // Delete Portfolio Transients
        $wpdb->query("DELETE FROM {$wpdb->options} WHERE `option_name` LIKE '_transient_qi_portf_item_%'");
        $wpdb->query("DELETE FROM {$wpdb->options} WHERE `option_name` LIKE '_transient_timeout_portf_item_%'");
        die('1');
    }
    die;
}