/**
  * Include required files
  **/
 function includes()
 {
     $includes = array('spyropress-admin-hooks.php', 'spyropress-admin-functions.php', framework_classes() . 'class-tgm-plugin-activation.php', 'ui/grid.php', 'ui/sub-heading.php', 'ui/toggle.php', 'ui/text-field.php', 'ui/text-area.php', 'ui/checkbox.php', 'ui/radio.php', 'ui/select.php', 'ui/hidden.php', 'ui/text-editor.php', 'ui/colorpicker.php', 'ui/datepicker.php', 'ui/upload.php', 'ui/typography.php', 'ui/repeater.php', 'ui/range-slider.php', 'ui/background.php', 'ui/info.php', 'ui/border.php', 'ui/padder.php', 'ui/import-export.php', 'ui/taxonomy.php', 'ui/custom-post.php', 'ui/skin-generator.php');
     foreach ($includes as $i) {
         require_once $i;
     }
     /** Theme and Framework Settings **/
     locate_template('includes/spyropress-settings-theme.php', true);
     /* Allow developers to include files before admin initialize */
     do_action('spyropress_admin_includes');
 }
Esempio n. 2
0
/**
 * Skin Generator
 */
function spyropress_skin_generator()
{
    // Security
    check_ajax_referer('skin_generator_form', 'skin_generator_nonce');
    $name = $_POST['skin_name'];
    $color = $_POST['skin_color'];
    $gradient = $_POST['skin_gradient'];
    if (empty($name) || empty($color)) {
        die;
    }
    // generate filename
    $filename = spyropress_uglify($name);
    $skin = template_path() . 'assets/less/skin.less';
    $css = template_path() . 'assets/css/skins/' . $filename . '.css';
    // Delte previous file
    if (file_exists($css)) {
        unlink($css);
    }
    // LESS
    require framework_classes() . 'class-lessc.php';
    $less = new lessc();
    $less->setFormatter('compressed');
    $less->setVariables(array('skinColor' => spyropress_validate_setting($color, 'colorpicker', 'skin_color', array()), 'gradient' => $gradient));
    $result = $less->compileFile($skin, $css);
    if ($result) {
        $skins = get_option('_spyropress_porto_skins');
        $skins = $skins ? $skins : array();
        $skins[$filename] = array('name' => $name, 'color' => $color, 'gradient' => $gradient);
        update_option('_spyropress_porto_skins', $skins);
    }
    // Refresh page
    echo 'window.location = "' . $_SERVER['HTTP_REFERER'] . '";';
    // Exit
    die;
}