/**
 * @since 4.4
 */
function vc_get_autocomplete_suggestion()
{
    if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
        die;
    }
    $query = vc_post_param('query');
    $tag = strip_tags(vc_post_param('shortcode'));
    $param_name = vc_post_param('param');
    vc_render_suggestion($query, $tag, $param_name);
}
 /**
  * Build edit form fields
  *
  * @deprecated 4.4
  * @use Vc_Shortcode_Edit_Form::renderFields
  */
 public function build()
 {
     if (!vc_verify_admin_nonce(vc_post_param('nonce')) || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
         wp_send_json(array('success' => false));
     }
     $tag = vc_post_param('element');
     $shortCode = stripslashes(vc_post_param('shortcode'));
     require_once vc_path_dir('EDITORS_DIR', 'class-vc-edit-form-fields.php');
     $fields = new Vc_Edit_Form_Fields($tag, shortcode_parse_atts($shortCode));
     $fields->render();
     die;
 }
/**
 * Remove Vc pointers keys to show Tour markers again.
 * @sine 4.5
 */
function vc_pointer_reset()
{
    global $vc_default_pointers;
    if (!vc_verify_admin_nonce() || !current_user_can('manage_options')) {
        die;
    }
    $pointers = (array) apply_filters('vc_pointers_list', $vc_default_pointers);
    $prev_meta_value = get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true);
    $dismissed = explode(',', (string) $prev_meta_value);
    if (count($dismissed) > 0 && count($pointers)) {
        $meta_value = implode(',', array_diff($dismissed, $pointers));
        update_user_meta(get_current_user_id(), 'dismissed_wp_pointers', $meta_value, $prev_meta_value);
    }
}
 /**
  *
  */
 public function goAction()
 {
     if (!vc_verify_admin_nonce() || !current_user_can('manage_options')) {
         die;
     }
     $action = vc_post_param('vc_action');
     $this->result($this->{$action}());
 }
 * Shortcode attributes
 * @var $atts
 * @var $css
 * @var $animation
 * @var $content - shortcode content
 * Shortcode class
 * @var $this WPBakeryShortCode_VC_Gitem_Animated_Block
 */
$css = $animation = $animation_attr = '';
extract(shortcode_atts(array('css' => '', 'animation' => ''), $atts));
$css_style = '';
$css_class = 'vc_gitem-animated-block ' . vc_shortcode_custom_css_class($css, ' ');
if (!empty($animation)) {
    $css_class .= ' vc_gitem-animate vc_gitem-animate-' . $animation;
    $animation_attr .= ' data-vc-animation="' . esc_attr($animation) . '"';
} elseif ('vc_gitem_preview' !== vc_request_param('action') && vc_verify_admin_nonce() && (current_user_can('edit_posts') || current_user_can('edit_pages'))) {
    $content = preg_replace('/(?<=\\[)(vc_gitem_zone_b\\b)/', '$1 render="no"', $content);
}
?>
<div class="<?php 
echo esc_attr($css_class);
?>
"<?php 
echo $animation_attr;
echo empty($css_style) ? '' : ' style="' . esc_attr($css_style) . '"';
?>
><?php 
echo do_shortcode($content);
?>
</div>
Example #6
0
<?php

if ('vc_edit_form' === vc_post_param('action') && vc_verify_admin_nonce()) {
    $link_category = array(__('All Links', 'js_composer') => '');
    $link_cats = get_terms('link_category');
    if (is_array($link_cats) && !empty($link_cats)) {
        foreach ($link_cats as $link_cat) {
            if (is_object($link_cat) && isset($link_cat->name, $link_cat->term_id)) {
                $link_category[$link_cat->name] = $link_cat->term_id;
            }
        }
    }
} else {
    $link_category = array();
}
return array('name' => 'WP ' . __('Links'), 'base' => 'vc_wp_links', 'icon' => 'icon-wpb-wp', 'category' => __('WordPress Widgets', 'js_composer'), 'class' => 'wpb_vc_wp_widget', 'content_element' => (bool) get_option('link_manager_enabled'), 'weight' => -50, 'description' => __('Your blogroll', 'js_composer'), 'params' => array(array('type' => 'dropdown', 'heading' => __('Link Category', 'js_composer'), 'param_name' => 'category', 'value' => $link_category, 'admin_label' => true), array('type' => 'dropdown', 'heading' => __('Order by', 'js_composer'), 'param_name' => 'orderby', 'value' => array(__('Link title', 'js_composer') => 'name', __('Link rating', 'js_composer') => 'rating', __('Link ID', 'js_composer') => 'id', __('Random', 'js_composer') => 'rand')), array('type' => 'checkbox', 'heading' => __('Options', 'js_composer'), 'param_name' => 'options', 'value' => array(__('Show Link Image', 'js_composer') => 'images', __('Show Link Name', 'js_composer') => 'name', __('Show Link Description', 'js_composer') => 'description', __('Show Link Rating', 'js_composer') => 'rating')), array('type' => 'textfield', 'heading' => __('Number of links to show', 'js_composer'), 'param_name' => 'limit', 'value' => -1), array('type' => 'textfield', 'heading' => __('Extra class name', 'js_composer'), 'param_name' => 'el_class', 'description' => __('Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer'))));
 /**
  * Create shortcode's string.
  *
  * @since  3.0
  * @access public
  * @deprecated
  */
 public function elementBackendHtml()
 {
     global $current_user;
     get_currentuserinfo();
     if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
         wp_send_json(array('success' => false));
     }
     $data_element = vc_post_param('data_element');
     /** @var $settings - get use group access rules */
     $settings = WPBakeryVisualComposerSettings::get('groups_access_rules');
     $role = $current_user->roles[0];
     if ($data_element === 'vc_column' && vc_post_param('data_width') !== null) {
         $output = do_shortcode('[vc_column width="' . vc_post_param('data_width') . '"]');
         echo $output;
     } elseif ($data_element == 'vc_row' || $data_element == 'vc_row_inner' || $data_element == 'mk_page_section') {
         $output = do_shortcode('[' . $data_element . ']');
         echo $output;
     } elseif (!isset($settings[$role]['shortcodes']) || isset($settings[$role]['shortcodes'][$data_element]) && (int) $settings[$role]['shortcodes'][$data_element] === 1) {
         $output = do_shortcode('[' . $data_element . ']');
         echo $output;
     }
     die;
 }
 /**
  * @since 4.4
  */
 public function delete()
 {
     if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
         die;
     }
     $template_id = vc_post_param('template_id');
     if (!isset($template_id) || $template_id === "") {
         die('Error: Vc_Templates_Panel_Editor::delete:1');
     }
     $saved_templates = get_option($this->option_name);
     unset($saved_templates[$template_id]);
     if (count($saved_templates) > 0) {
         update_option($this->option_name, $saved_templates);
     } else {
         delete_option($this->option_name);
     }
     die;
 }
Example #9
0
/**
 * @since 4.2
 */
function vc_get_loop_settings_json()
{
    if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
        die;
    }
    $loop_settings = new VcLoopSettings(vc_post_param('value'), vc_post_param('settings'));
    $loop_settings->render();
    die;
}
/**
 * Return rendered title prompt
 *
 * @since 4.7
 *
 * @return string
 */
function vc_action_render_settings_preset_title_prompt()
{
    if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
        wp_send_json(array('success' => false));
    }
    ob_start();
    vc_include_template(apply_filters('vc_render_settings_preset_title_prompt', 'editors/partials/prompt.tpl.php'));
    $html = ob_get_clean();
    $response = array('success' => true, 'html' => $html);
    wp_send_json($response);
}
 /**
  *
  */
 public function deactivate()
 {
     if (!vc_verify_admin_nonce() || !current_user_can('manage_options')) {
         die;
     }
     $params = array();
     $params['dkey'] = $this->deactivation();
     $string = 'deactivatelicense?';
     $request_url = self::getWpbControlUrl(array($string, http_build_query($params, '', '&')));
     $response = wp_remote_get($request_url, array('timeout' => 300));
     if (is_wp_error($response)) {
         echo json_encode(array('result' => false));
         die;
     }
     $result = json_decode($response['body']);
     if ((bool) $result->result) {
         $this->setDeactivation('');
     }
     echo $response['body'];
     die;
 }
function vc_gitem_set_mapper_check_access()
{
    if (vc_verify_admin_nonce() && (current_user_can('edit_posts') || current_user_can('edit_pages')) && 'true' === vc_post_param('vc_grid_item_editor')) {
        vc_mapper()->setCheckForAccess(false);
    }
}
 /**
  * @todo move it
  * @since 4.2
  */
 public function galleryHTML()
 {
     if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
         wp_send_json(array('success' => false));
     }
     $images = vc_post_param('content');
     if (!empty($images)) {
         echo fieldAttachedImages(explode(',', $images));
     }
     die;
 }
 /**
  * Used in templates.js:changeShortcodeParams
  * @todo make sure we need this
  * Output some template content
  * @todo make sure it is secure?
  */
 public function loadHtml()
 {
     if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
         die;
     }
     $id = vc_post_param('id');
     $post = get_post((int) $id);
     if ($post->post_type == self::$post_type) {
         echo $post->post_content;
     }
     die;
 }
Example #15
0
	/**
	 * Set VC mode.
	 *
	 * Mode depends on which page is requested by client from server and request parameters like vc_action.
	 *
	 * @since  4.2
	 * @access protected
	 *
	 * @return void
	 */
	protected function setMode() {
		/**
		 * TODO: Create another system (When ajax rebuild).
		 * Use vc_action param to define mode.
		 * 1. admin_frontend_editor - set by editor or request param
		 * 2. admin_backend_editor - set by editor or request param
		 * 3. admin_frontend_editor_ajax - set by request param
		 * 4. admin_backend_editor_ajax - set by request param
		 * 5. admin_updater - by vc_action
		 * 6. page_editable - by vc_action
		 */
		if ( is_admin() ) {
			if ( vc_action() === 'vc_inline' && ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) ) {
				$this->mode = 'admin_frontend_editor';
			} elseif ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && (
					vc_action() === 'vc_upgrade' ||
					( vc_get_param( 'action' ) === 'update-selected' && vc_get_param( 'plugins' ) === $this->pluginName() )
				) ) {
				$this->mode = 'admin_updater';
			} elseif ( current_user_can( 'manage_options' ) && isset( $_GET['page'] ) && $_GET['page'] === $this->settings()->page() ) {
				$this->mode = 'admin_settings_page';
			} else {
				$this->mode = 'admin_page';
			}
		} else {
			if ( vc_verify_admin_nonce() && current_user_can( 'edit_post', (int) vc_request_param( 'vc_post_id' ) ) && isset( $_GET['vc_editable'] ) && 'true' === $_GET['vc_editable'] ) {
				$this->mode = 'page_editable';
			} else {
				$this->mode = 'page';
			}
		}
	}
/**
 * Generate filter preview
 *
 * Preview url is generated as data uri (base64)
 *
 * Required _POST params:
 * - string filter: filter name
 * - int attachment_id: attachment id
 *
 * @return void Results are sent out as json
 */
function vc_media_editor_preview_image()
{
    if (!vc_verify_admin_nonce() || !current_user_can('upload_files')) {
        die;
    }
    require_once vc_path_dir('APP_ROOT', 'vendor/mmihey/PHP-Instagram-effects/src/Image/Filter.php');
    $response = array('success' => true, 'data' => array('src' => ''));
    $filter_name = vc_post_param('filter', '');
    $attachment_id = vc_post_param('attachment_id', false);
    $preferred_size = vc_post_param('preferred_size', 'medium');
    if (!$filter_name || !$attachment_id) {
        wp_send_json($response);
    }
    $attachment_path = get_attached_file($attachment_id);
    $attachment_details = wp_prepare_attachment_for_js($attachment_id);
    if (!isset($attachment_details['sizes'][$preferred_size])) {
        $preferred_size = 'thumbnail';
    }
    $attachment_url = wp_get_attachment_image_src($attachment_id, $preferred_size);
    if (empty($attachment_path) || empty($attachment_url[0])) {
        wp_send_json($response);
    }
    $source_path = dirname($attachment_path) . '/' . basename($attachment_url[0]);
    $image = vc_get_gd_resource($source_path);
    if (!$image) {
        wp_send_json($response);
    }
    $Filter = new vcImageFilter($image);
    $Filter->{$filter_name}();
    $extension = strtolower(pathinfo($source_path, PATHINFO_EXTENSION));
    ob_start();
    switch ($extension) {
        case 'jpeg':
        case 'jpg':
            imagejpeg($Filter->getImage());
            break;
        case 'png':
            imagepng($Filter->getImage());
            break;
        case 'gif':
            imagegif($Filter->getImage());
            break;
    }
    $data = ob_get_clean();
    $response['data']['src'] = 'data:image/' . $extension . ';base64,' . base64_encode($data);
    wp_send_json($response);
}
Example #17
0
 /**
  * Used in templates.js:changeShortcodeParams
  * @todo make sure we need this
  * Output some template content
  * @todo make sure it is secure?
  */
 public function loadHtml()
 {
     if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
         die;
     }
     $id = vc_post_param('id');
     $post = get_post((int) $id);
     if (!$post) {
         die(__('Wrong template', 'templatera'));
     }
     if ($this->isSamePostType($post->post_type)) {
         echo $post->post_content;
     }
     die;
 }
 /**
  * Get attribute terms hooks from ajax request
  * @since 4.4
  */
 public function getAttributeTermsAjax()
 {
     if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
         die;
     }
     $attribute = vc_post_param('attribute');
     $values = $this->getAttributeTerms($attribute);
     $param = array('param_name' => 'filter', 'type' => 'checkbox');
     $param_line = '';
     foreach ($values as $label => $v) {
         $param_line .= ' <label class="vc_checkbox-label"><input id="' . $param['param_name'] . '-' . $v . '" value="' . $v . '" class="wpb_vc_param_value ' . $param['param_name'] . ' ' . $param['type'] . '" type="checkbox" name="' . $param['param_name'] . '"' . '> ' . $label . '</label>';
     }
     die(json_encode($param_line));
 }
Example #19
0
/**
 * @since 4.4
 */
function vc_param_group_clone()
{
    if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
        die;
    }
    $param = vc_post_param('param');
    $value = vc_post_param('value');
    $tag = vc_post_param('shortcode');
    die(vc_param_group_clone_by_data($tag, json_decode(urldecode($param), true), json_decode(urldecode($value), true)));
}
 /**
  * Load default template content by index from ajax
  * @deprecated 4.4 moved to Vc_Templates_Panel_Editor::getBackendDefaultTemplate(), will be removed
  * @moved to Vc_Templates_Panel_Editor
  *
  * @param bool $return | should function return data or not
  *
  * @return string
  */
 public function getBackendDefaultTemplate($return = false)
 {
     if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) {
         wp_send_json(array('success' => false));
     }
     return visual_composer()->templatesPanelEditor()->getBackendDefaultTemplate($return);
 }