Exemplo n.º 1
0
function hocwp_setup_theme_change_default_data()
{
    if (hocwp_is_localhost()) {
        $page = hocwp_get_post_by_slug('sample-page', 'page');
        if (is_a($page, 'WP_Post')) {
            $data = array('ID' => $page->ID, 'post_title' => 'Giới thiệu', 'post_name' => 'gioi-thieu');
            wp_update_post($data);
        }
    }
}
<?php

if (!function_exists('add_filter')) {
    exit;
}
global $pagenow;
$parent_slug = 'tools.php';
$option = new HOCWP_Option(__('Developers', 'hocwp-theme'), 'hocwp_developers');
$option->set_parent_slug($parent_slug);
$option->disable_sidebar();
$option->add_field(array('id' => 'compress_css', 'title' => __('Compress CSS', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Compress all style in current theme or plugins?', 'hocwp-theme'), 'default' => 1));
$option->add_field(array('id' => 'compress_js', 'title' => __('Compress Javascript', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Compress all javascript in current theme or plugins?', 'hocwp-theme'), 'default' => 1));
$option->add_field(array('id' => 'compress_core', 'title' => __('Compress Core', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Compress core styles and scripts?', 'hocwp-theme'), 'default' => 1));
$option->add_field(array('id' => 're_compress', 'title' => __('Recompress', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Check here if you want to recompress all minified files?', 'hocwp-theme')));
$option->add_field(array('id' => 'force_compress', 'title' => __('Force Compress', 'hocwp-theme'), 'field_callback' => 'hocwp_field_input_checkbox', 'label' => __('Disable compress cache each 15 minutes?', 'hocwp-theme')));
$option->add_field(array('id' => 'compress_css_js', 'field_callback' => 'hocwp_field_button', 'value' => __('Compress CSS and Javascript', 'hocwp-theme')));
if (HOCWP_DEVELOPING && hocwp_is_localhost()) {
    $option->init();
}
hocwp_option_add_object_to_list($option);
Exemplo n.º 3
0
function hocwp_setup_admin_body_class($class)
{
    if (HOCWP_DEVELOPING && hocwp_is_localhost()) {
        hocwp_add_string_with_space_before($class, 'hocwp-developing');
    }
    return $class;
}
 public function check_from_server($args = array())
 {
     $transient_name = hocwp_build_transient_name('hocwp_check_license_from_server_%s', $args);
     if (false === ($valid = get_transient($transient_name))) {
         $customer_email = hocwp_get_value_by_key($args, 'customer_email', hocwp_get_value_by_key($args, 'email', hocwp_get_admin_email()));
         if (!is_email($customer_email)) {
             $customer_email = hocwp_get_admin_email();
         }
         $code = hocwp_get_value_by_key($args, 'license_code', hocwp_get_value_by_key($args, 'code'));
         $domain = hocwp_get_value_by_key($args, 'customer_domain', hocwp_get_value_by_key($args, 'domain', home_url()));
         $use_for = hocwp_get_value_by_key($args, 'use_for');
         if (empty($domain)) {
             $domain = esc_url(hocwp_get_root_domain_name(home_url()));
         }
         $meta_item = array('relation' => 'AND', array('key' => 'customer_domain', 'value' => untrailingslashit(esc_url(hocwp_get_root_domain_name($domain)))), array('key' => 'forever_domain', 'value' => 1, 'type' => 'numeric'));
         if (hocwp_is_localhost()) {
             array_push($meta_item, array('key' => 'customer_email', 'value' => sanitize_email($customer_email)));
         }
         $data = hocwp_api_get_by_meta($meta_item, 'license-api');
         if (hocwp_array_has_value($data)) {
             $valid = true;
         } else {
             $meta_item = array('relation' => 'AND', array('key' => 'customer_email', 'value' => sanitize_email($customer_email)), array('key' => 'forever_email', 'value' => 1, 'type' => 'numeric'), array('key' => 'use_for', 'value' => $use_for));
             $data = hocwp_api_get_by_meta($meta_item, 'license-api');
             if (hocwp_array_has_value($data)) {
                 $valid = true;
             } else {
                 $meta_item = array('relation' => 'AND', array('key' => 'customer_domain', 'value' => esc_url(untrailingslashit($domain))), array('key' => 'customer_email', 'value' => sanitize_email($customer_email)), array('key' => 'license_code', 'value' => $code), array('key' => 'use_for', 'value' => $use_for));
                 $data = hocwp_api_get_by_meta($meta_item, 'license-api');
                 if (hocwp_array_has_value($data)) {
                     $valid = true;
                 }
             }
         }
         set_transient($transient_name, $valid, 15 * MINUTE_IN_SECONDS);
     }
     $valid = (bool) $valid;
     return apply_filters('hocwp_check_license_on_server', $valid, $args);
 }