public function addMediaButton($editor_id)
 {
     $this->enqueue();
     $title = sprintf(__('Insert Shortcodes', csl18n()));
     $contents = (include CS()->path('includes/builder/svg/nav-elements-solid.php'));
     echo "<button href=\"#\" title=\"{$title}\" id=\"cs-insert-shortcode-button\" class=\"button cs-insert-btn\">{$contents}</button>";
 }
Ejemplo n.º 2
0
 public static function preInit()
 {
     global $wp_version;
     if (version_compare($wp_version, '4.1', '<')) {
         require_once CS()->path('includes/utility/wp-json.php');
     }
 }
 public function ajax_handler($data)
 {
     CS_Shortcode_Preserver::init();
     if ($this->sandbox_the_content) {
         CS_Shortcode_Preserver::sandbox('cs_render_the_content');
     }
     add_filter('cs_preserve_shortcodes_no_wrap', '__return_true');
     $this->orchestrator = $this->plugin->component('Element_Orchestrator');
     $this->orchestrator->load_elements();
     $this->mk1 = new Cornerstone_Legacy_Renderer($this->plugin->component('Legacy_Elements'));
     global $post;
     if (!isset($data['post_id']) || !($post = get_post((int) $data['post_id']))) {
         wp_send_json_error(array('message' => 'post_id not set'));
     }
     setup_postdata($post);
     $this->enqueue_extractor = $this->plugin->loadComponent('Enqueue_Extractor');
     $this->enqueue_extractor->start();
     if (isset($data['raw_markup'])) {
         $this->raw_markup = (bool) $data['raw_markup'];
     }
     if (!isset($data['batch'])) {
         wp_send_json_error(array('message' => 'No element data recieved'));
     }
     $jobs = $this->batch($data['batch']);
     $scripts = $this->enqueue_extractor->get_scripts();
     if (is_wp_error($jobs)) {
         wp_send_json_error(array('message' => $jobs->get_error_message()));
     }
     $result = array('jobs' => $jobs, 'scripts' => $scripts);
     //Suppress PHP error output unless debugging
     if (CS()->common()->isDebug()) {
         return wp_send_json_success($result);
     }
     return @wp_send_json_success($result);
 }
Ejemplo n.º 4
0
 /**
  * Load generated CSS output and place style tag in wp_head
  */
 public function inlineStyles()
 {
     ob_start();
     echo '<style id="cornerstone-generated-preview-css" type="text/css">';
     $settings = CS()->settings();
     $options = CS()->customizer()->optionData();
     extract($settings);
     extract($options);
     include CS()->path() . 'includes/builder/styles.php';
     do_action('cornerstone_generated_preview_css');
     echo '</style>';
     $css = ob_get_contents();
     ob_end_clean();
     //
     // 1. Remove comments.
     // 2. Remove whitespace.
     // 3. Remove starting whitespace.
     //
     $output = preg_replace('#/\\*.*?\\*/#s', '', $css);
     // 1
     $output = preg_replace('/\\s*([{}|:;,])\\s+/', '$1', $output);
     // 2
     $output = preg_replace('/\\s\\s+(.*)/', '$1', $output);
     // 3
     echo $output;
 }
 public function __construct()
 {
     /* Get all saved data and put them in self::$settings for later use */
     self::$settings = CS()->settings();
     /* Handles post data */
     if (isset($_POST['cornerstone_options_submitted']) && isset($_POST['cornerstone-fields'])) {
         if (strip_tags($_POST['cornerstone_options_submitted']) == 'submitted' && current_user_can('manage_options')) {
             $fields = $_POST['cornerstone-fields'];
             // Empty checkboxes
             if (isset($_POST['cornerstone-checkboxes'])) {
                 foreach ($_POST['cornerstone-checkboxes'] as $name) {
                     if (!in_array($name, $fields)) {
                         self::$settings[$name] = array();
                     }
                 }
             }
             // Convert checkbox to boolean
             if (isset($_POST['cornerstone-checkbox'])) {
                 foreach ($_POST['cornerstone-checkbox'] as $name) {
                     self::$settings[$name] = in_array($name, $fields);
                 }
             }
             foreach ($fields as $name => $value) {
                 // remove html tags
                 self::$settings[$name] = is_array($value) ? array_map('strip_tags', $value) : strip_tags($value);
             }
             update_option('cornerstone_settings', self::$settings);
         }
     }
 }
 public function addMediaButton($editor_id)
 {
     $this->enqueue();
     $title = sprintf(__('Insert Shortcodes', csl18n()));
     $contents = CS()->view('svg/nav-elements-solid', false);
     echo "<button href=\"#\" title=\"{$title}\" id=\"cs-insert-shortcode-button\" class=\"button cs-insert-btn\">{$contents}</button>";
 }
Ejemplo n.º 7
0
 public function controls()
 {
     global $post;
     $url = add_query_arg(array('url' => CS()->common()->getEditURL(get_the_id())), admin_url('customize.php'));
     $link = '<a href="' . $url . '">' . __('Customizer', csl18n()) . '</a>';
     $html = '<ul class="cs-controls"><li class="cs-control cs-control-info-box"><h4>' . __('Looking for global styling?', csl18n()) . '</h4><p>' . sprintf(__('Sitewide styles outside of the content area are managed via the %s.', csl18n()), $link) . '</p></li></ul>';
     return array('customizer_message' => array('type' => 'custom-markup', 'ui' => array(), 'options' => array('html' => $html)));
 }
Ejemplo n.º 8
0
 /**
  * Get an array of post types allowed for Cornerstone.
  * This is based on both user role, and enabled post types
  * @return array
  */
 public function getAllowedPostTypes()
 {
     $settings = CS()->settings();
     $user = wp_get_current_user();
     if (!empty($user) && (user_can($user, 'manage_options') || count(array_intersect($settings['permitted_roles'], (array) $user->roles)) > 0)) {
         return apply_filters('cornerstone_allowed_post_types', $settings['allowed_post_types']);
     }
     return array();
 }
Ejemplo n.º 9
0
 public static function preInit()
 {
     // Disable NextGEN Resource Manager
     add_filter('run_ngg_resource_manager', '__return_false');
     global $wp_version;
     if (version_compare($wp_version, '4.1', '<')) {
         require_once CS()->path('includes/utility/wp-json.php');
     }
 }
 public function setup()
 {
     // Disable revision through filter
     if (apply_filters('cornerstone_disable_revisions', false) || !CS()->common()->uses_cornerstone()) {
         return;
     }
     // Save cornerstone revision
     add_action('save_post', array($this, 'saveRevision'), 10, 2);
     // Restore cornerstone revision
     add_action('wp_restore_post_revision', array($this, 'restoreRevision'), 10, 2);
 }
Ejemplo n.º 11
0
 public function handler($data)
 {
     global $post;
     $settings = get_post_meta($post->ID, '_cornerstone_settings', true);
     $settings['responsive_text'] = isset($data['elements']) ? $data['elements'] : array();
     update_post_meta($post->ID, '_cornerstone_settings', $settings);
     $save_handler = CS()->component('Save_Handler');
     foreach ($settings['responsive_text'] as $element) {
         $save_handler->append_element($element);
     }
 }
Ejemplo n.º 12
0
 /**
  * Instantiate
  */
 public function setup()
 {
     $this->fontIcons = $this->plugin->config('common/font-icons');
     add_action('init', array($this, 'init'));
     $version = CS()->version();
     if (false !== strpos($version, '-alpha')) {
         $this->plugin->loadComponent('Alpha');
     }
     if (false !== strpos($version, '-')) {
         $this->plugin->loadComponent('Prerelease');
     }
 }
 public function __construct($data, $parent = null)
 {
     $this->parent = $parent;
     $this->data = $data;
     $type = isset($this->data['_type']) ? $this->data['_type'] : 'undefined';
     $this->definition = CS()->component('Element_Orchestrator')->get($type);
     if (isset($data['elements'])) {
         unset($this->data['elements']);
         foreach ($data['elements'] as $element) {
             $this->elements[] = new self($element, $this);
         }
     }
 }
 public function ajaxResponseDelete()
 {
     if (!isset($_POST['slug'])) {
         return wp_send_json_error('Invalid request.');
     }
     $query = new WP_Query(array('post_type' => 'cs_user_templates', 'meta_key' => 'cs_template_slug', 'meta_value' => $_POST['slug']));
     if ($query->post && wp_delete_post($query->post->ID, true)) {
         if (CS()->common()->isDebug()) {
             return wp_send_json_success();
         }
         return @wp_send_json_success();
     }
     return wp_send_json_error('Unable to delete template.');
 }
Ejemplo n.º 15
0
function x_pairing_notice()
{
    if (x_plugin_cornerstone_exists() && class_exists('CS')) {
        if (!defined('X_CURRENT') || version_compare(CS()->version(), X_CORNERSTONE_CURRENT, '<')) {
            ?>

      <div class="updated x-notice warning">
        <p><strong>IMPORTANT: Please update Cornerstone</strong>. You are using a newer version of X that may not be compatible. After updating, please ensure that you have cleared out your browser cache and any caching plugins you may be using. This message will self destruct upon updating Cornerstone.</p>
      </div>

    <?php 
        }
    }
}
Ejemplo n.º 16
0
 public function loadNativePages()
 {
     $path = CS()->path() . 'includes/modules/layout_templates/';
     foreach (glob("{$path}page-*.php") as $filename) {
         if (!file_exists($filename)) {
             continue;
         }
         $data = (include $filename);
         $data['type'] = 'page';
         $data['slug'] = 'themeco-' . trim(str_replace('.php', '', basename($filename)));
         $data['section'] = 'themeco-pages';
         $this->registry[] = $data;
     }
 }
Ejemplo n.º 17
0
 /**
  * Load all element classes from the elements folder.
  * Elements are loaded by a convention of lowercase filenames and capitalized class names.
  * Once the classes are loaded, each one is added to the manager library
  * @return none
  */
 public function loadNativeElements()
 {
     $this->elements = array();
     $path = CS()->path() . 'includes/modules/elements/';
     foreach (glob("{$path}*.php") as $filename) {
         if (!file_exists($filename)) {
             continue;
         }
         require_once $filename;
         $words = explode('-', str_replace('.php', '', basename($filename)));
         foreach ($words as $key => $value) {
             $words[$key] = ucfirst($value);
         }
         $class_name = $this->class_prefix . implode('_', $words);
         $this->add($class_name);
     }
 }
Ejemplo n.º 18
0
 public static final function mixinFactory($name, $config = array())
 {
     $mixins = CS()->config('controls/mixins');
     $type = $config['mixin'];
     unset($config['mixin']);
     if (!isset($mixins[$type])) {
         return new WP_Error('cornerstone', "Mixin '{$type}' not found.");
     }
     // Set a maximium merge depth. This allows top level keys to be merged,
     // but allows full arrays to be overriden at the control option level.
     $depth = 3;
     // For groups, we need an additional level of merge depth
     if (isset($config['group']) && $config['group'] === true || isset($mixins[$type]['group']) && $mixins[$type]['group'] === true) {
         $depth = 4;
     }
     return self::factory($name, cs_deep_array_merge($config, $mixins[$type], $depth));
 }
 /**
  * Register integrations included with Cornerstone
  * @return none
  */
 public function registerNativeIntegrations()
 {
     $this->registry = array();
     $this->themes = array();
     $path = CS()->path() . 'includes/modules/integrations/';
     foreach (glob("{$path}*.php") as $filename) {
         if (!file_exists($filename)) {
             continue;
         }
         require_once $filename;
         $handle = str_replace('.php', '', basename($filename));
         $words = explode('-', $handle);
         foreach ($words as $key => $value) {
             $words[$key] = ucfirst($value);
         }
         $this->registry[$handle] = 'Cornerstone_Integration_' . implode('_', $words);
     }
 }
 /**
  * Register Customizer Sections, Settings, and Controls.
  */
 public function register($wp_customize)
 {
     $cs = array();
     include CS()->path('includes/customizer/register.php');
     //
     // Output - Sections.
     //
     foreach ($cs['sec'] as $section) {
         $wp_customize->add_section($section[0], array('title' => $section[1], 'priority' => $section[2]));
     }
     //
     // Output - Settings.
     //
     foreach ($cs['set'] as $setting) {
         $wp_customize->add_setting($setting[0], array('type' => 'option', 'default' => $this->defaults[$setting[0]], 'transport' => 'refresh'));
     }
     //
     // Output - Controls.
     //
     foreach ($cs['con'] as $control) {
         static $i = 1;
         if ($control[1] == 'radio') {
             $wp_customize->add_control($control[0], array('type' => $control[1], 'label' => $control[2], 'section' => $control[4], 'priority' => $i, 'choices' => $control[3]));
         } elseif ($control[1] == 'select') {
             $wp_customize->add_control($control[0], array('type' => $control[1], 'label' => $control[2], 'section' => $control[4], 'priority' => $i, 'choices' => $control[3]));
         } elseif ($control[1] == 'slider') {
             $wp_customize->add_control(new X_Customize_Control_Slider($wp_customize, $control[0], array('label' => $control[2], 'section' => $control[4], 'settings' => $control[0], 'priority' => $i, 'choices' => $control[3])));
         } elseif ($control[1] == 'text') {
             $wp_customize->add_control($control[0], array('type' => $control[1], 'label' => $control[2], 'section' => $control[3], 'priority' => $i));
         } elseif ($control[1] == 'textarea') {
             $wp_customize->add_control(new X_Customize_Control_Textarea($wp_customize, $control[0], array('label' => $control[2], 'section' => $control[3], 'settings' => $control[0], 'priority' => $i)));
         } elseif ($control[1] == 'checkbox') {
             $wp_customize->add_control($control[0], array('type' => $control[1], 'label' => $control[2], 'section' => $control[3], 'priority' => $i));
         } elseif ($control[1] == 'color') {
             $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $control[0], array('label' => $control[2], 'section' => $control[3], 'settings' => $control[0], 'priority' => $i)));
         } elseif ($control[1] == 'image') {
             $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, $control[0], array('label' => $control[2], 'section' => $control[3], 'settings' => $control[0], 'priority' => $i)));
         }
         $i++;
     }
 }
Ejemplo n.º 21
0
 public function ajax_handler($data)
 {
     if (!isset($data['elements'])) {
         wp_send_json_error(array('message' => 'No element data recieved'));
     }
     if (!isset($data['settings'])) {
         wp_send_json_error(array('message' => 'No setting data recieved'));
     }
     if (!is_array($data['elements'])) {
         wp_send_json_error(array('message' => 'Element data invalid'));
     }
     if (!is_array($data['settings'])) {
         wp_send_json_error(array('message' => 'Setting data invalid'));
     }
     global $post;
     if (!isset($data['post_id']) || !($post = get_post((int) $data['post_id']))) {
         wp_send_json_error(array('message' => 'post_id not set'));
     }
     setup_postdata($post);
     $this->append = array();
     $this->post_id = $data['post_id'];
     $this->legacy = new Cornerstone_Legacy_Renderer($this->plugin->component('Legacy_Elements'));
     $settings = $this->save_settings($data['settings']);
     if (is_wp_error($settings)) {
         wp_send_json_error(array('message' => $settings->get_error_message()));
     }
     $elements = $this->save_elements($data['elements']);
     wp_reset_postdata();
     if (is_wp_error($elements)) {
         wp_send_json_error(array('message' => $elements->get_error_message()));
     }
     update_post_meta($this->post_id, '_cornerstone_version', $this->plugin->version());
     $result = array('elements' => $elements, 'settings' => $settings);
     //Suppress PHP error output unless debugging
     if (CS()->common()->isDebug()) {
         $result['debug'] = array('memory' => memory_get_peak_usage());
         return wp_send_json_success($result);
     }
     return @wp_send_json_success($result);
 }
Ejemplo n.º 22
0
 /**
  * Respond to AJAX request
  */
 public static function ajaxHandler()
 {
     global $post;
     if (!isset($_POST['post_id']) || !($post = get_post((int) $_POST['post_id']))) {
         wp_send_json_error(array('message' => 'post_id not set'));
     }
     setup_postdata($post);
     if (!isset($_POST['request'])) {
         wp_send_json_error(array('message' => 'No element data recieved'));
     }
     $json = stripslashes($_POST['request']);
     $data = json_decode($json, true);
     $result = self::$instance->batch($data);
     if (is_wp_error($result)) {
         wp_send_json_error(array('message' => $result->get_error_message()));
     }
     // Suppress PHP error output unless debugging
     if (CS()->common()->isDebug()) {
         return wp_send_json_success($result);
     }
     return @wp_send_json_success($result);
 }
 /**
  * Load generated CSS output and place style tag in wp_head
  */
 public function inlineStyles()
 {
     ob_start();
     if (apply_filters('cornerstone_inline_styles', true)) {
         $settings = CS()->settings();
         $options = CS()->customizer()->optionData();
         extract($settings);
         extract($options);
         echo '<style id="cornerstone-generated-css" type="text/css">';
         include CS()->path() . 'includes/shortcodes/styles.php';
         do_action('cornerstone_head_css');
         echo '</style>';
     }
     if (has_action('cornerstone_custom_css')) {
         echo '<style id="cornerstone-custom-css" type="text/css">';
         do_action('cornerstone_custom_css');
         echo '</style>';
     }
     if (apply_filters('_cornerstone_custom_css', isset($this->postSettings['custom_css']))) {
         echo '<style id="cornerstone-custom-page-css" type="text/css">';
         echo $this->postSettings['custom_css'];
         do_action('cornerstone_custom_page_css');
         echo '</style>';
     }
     $css = ob_get_contents();
     ob_end_clean();
     //
     // 1. Remove comments.
     // 2. Remove whitespace.
     // 3. Remove starting whitespace.
     //
     $output = preg_replace('#/\\*.*?\\*/#s', '', $css);
     // 1
     $output = preg_replace('/\\s*([{}|:;,])\\s+/', '$1', $output);
     // 2
     $output = preg_replace('/\\s\\s+(.*)/', '$1', $output);
     // 3
     echo $output;
 }
Ejemplo n.º 24
0
{
    return crc32($Str);
}
$count = 0;
//for($i=8;$i<20;$i++)
//{
$i = 0;
$collisions = 0;
$CA = array();
$CSA = array();
foreach ($Lines as $Line0) {
    if (!trim($Line0)) {
        continue;
    }
    $Line = explode('%', $Line0);
    $CS = CS($Line[0], $i);
    if (isset($CSA[$CS])) {
        $CA[$Line[0]] = $Line[1];
        $collisions++;
    } else {
        $CSA[$CS] = $Line0;
    }
    //echo $CSA[$CS];
    $count++;
    //if($count===100)
    //	break;
}
echo ' ' . $collisions . '<br /><pre>';
$res = '';
foreach ($CA as $Name => $Val) {
    $res .= "'{$Name}'=>{$Val}, ";
Ejemplo n.º 25
0
 public function register()
 {
     wp_register_style('cs-huebert-style', CS()->css('admin/huebert'), array(), CS()->version());
     wp_register_script('cs-huebert', CS()->js('admin/huebert'), array('underscore', 'jquery'), CS()->version(), true);
 }
Ejemplo n.º 26
0
 public function sanitize_elements($elements)
 {
     $orchestrator = CS()->component('Element_Orchestrator');
     $orchestrator->load_elements();
     $sanitized = array();
     foreach ($elements as $element) {
         if (!isset($element['_type'])) {
             continue;
         }
         $definition = $orchestrator->get($element['_type']);
         $sanitized[] = $definition->sanitize($element);
     }
     return $sanitized;
 }
Ejemplo n.º 27
0
 public function handler($data)
 {
     global $post;
     $settings = get_post_meta($post->ID, '_cornerstone_settings', true);
     $update = array();
     if (isset($data['post_title'])) {
         $update['post_title'] = $data['post_title'];
     }
     if (isset($data['allow_comments'])) {
         $update['comment_status'] = $data['allow_comments'] == 'true' ? 'open' : 'closed';
     }
     if (current_user_can($this->manager->post_type_object->cap->publish_posts)) {
         $update['post_status'] = $data['post_status'];
     }
     if (post_type_supports($post->post_type, 'page-attributes')) {
         $page_templates = wp_get_theme()->get_page_templates($post);
         $update['page_template'] = 'default';
         if (isset($data['page_template']) && isset($page_templates[$data['page_template']])) {
             $update['page_template'] = $data['page_template'];
         }
         if (isset($data['post_parent'])) {
             $update['post_parent'] = (int) $data['post_parent'];
         }
     }
     if (isset($data['custom_css'])) {
         $settings['custom_css'] = $data['custom_css'];
     }
     // Update Custom JS
     if (isset($data['custom_js']) && current_user_can('unfiltered_html')) {
         $settings['custom_js'] = $data['custom_js'];
     }
     // Minify JS
     if (isset($settings['custom_js'])) {
         require CS()->path('includes/utility/jsqueeze.php');
         $jz = new JSqueeze();
         $minified = $jz->squeeze($settings['custom_js']);
         if ($minified == ';') {
             $minified = '';
         }
         $settings['custom_js_mini'] = $minified;
     }
     if (!empty($update)) {
         $update['ID'] = $post->ID;
         $result = wp_update_post($update, true);
         if (is_wp_error($result)) {
             return $result;
         }
     }
     update_post_meta($post->ID, '_cornerstone_settings', $settings);
 }
Ejemplo n.º 28
0
    /**
     *
     */
    public function legacyFontClasses()
    {
        ?>
		<tr>
	    <th>
	      <label for="cornerstone-fields-enable_legacy_font_classes">
	        <strong><?php 
        _e('Enable Legacy Font Classes', csl18n());
        ?>
</strong>
	        <span><?php 
        _e('Check to enable legacy font classes.', csl18n());
        ?>
</span>
	      </label>
	    </th>
	    <td>
	      <fieldset>
	        <?php 
        echo CS()->component('Admin')->settings->renderField('enable_legacy_font_classes', array('type' => 'checkbox', 'value' => '1', 'label' => 'Enable'));
        ?>
	      </fieldset>
	    </td>
	  </tr>

	  <?php 
    }
Ejemplo n.º 29
0
 */
?>

<div class="wrap cs-admin">
  <h2><?php 
echo $title;
?>
</h2>
  <div id="poststuff">
    <div id="post-body" class="metabox-holder columns-2">
      <form name="cornerstone_options" method="post" action="">
        <input name="cornerstone_options_submitted" type="hidden" value="submitted">
        <div id="post-body-content">
          <div class="meta-box-sortables ui-sortable">

            <?php 
include CS()->path() . 'includes/admin/views/options-main.php';
?>
            
          </div>
        </div>

        <?php 
include CS()->path() . 'includes/admin/views/options-sidebar.php';
?>

      </form>
    </div>
    <br class="clear">
  </div>
</div>
Ejemplo n.º 30
0
 public function controls()
 {
     $this->addControl('content', 'editor', __('Content', csl18n()), __('Enter your Promo content.', csl18n()), '');
     $this->addControl('image', 'image', __('Promo Image &amp; Alt Text', csl18n()), __('Include an image for your Promo element and provide the alt text in the input below. Alt text is used to describe an image to search engines.', csl18n()), CS()->common()->placeholderImage(650, 1500));
     $this->addControl('alt', 'text', NULL, NULL, '');
 }