function msp_generate_buttons_css() { // load and get parser $parser = msp_get_parser(); $buttons_style = msp_get_option('buttons_style', ''); return $parser->get_buttons_styles($buttons_style); }
/** * Save ajax handler for main panel data * * @since 1.0.0 */ public function save_panel_ajax() { header("Content-Type: application/json"); // verify nonce if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], "msp_panel")) { echo json_encode(array('success' => false, 'message' => __("Authorization failed!", 'master-slider'))); exit; } // ignore the request if the current user doesn't have sufficient permissions if (!current_user_can('publish_masterslider')) { echo json_encode(array('success' => false, 'message' => apply_filters('masterslider_insufficient_permissions_to_publish_message', __("Sorry, You don't have enough permission to publish slider!", 'master-slider')))); exit; } ///////////////////////////////////////////////////////////////////////////////////////// // Get the slider id $slider_id = isset($_REQUEST['slider_id']) ? $_REQUEST['slider_id'] : ''; if (empty($slider_id)) { echo json_encode(array('success' => false, 'type' => 'save', 'message' => __("Slider id is not defined.", 'master-slider'))); exit; } // get the slider type $slider_type = isset($_REQUEST['slider_type']) ? $_REQUEST['slider_type'] : 'custom'; // get panel data $msp_data = isset($_REQUEST['msp_data']) ? $_REQUEST['msp_data'] : NULL; // get parse and database tools global $mspdb; // load and get parser and start parsing data $parser = msp_get_parser(); $parser->set_data($msp_data, $slider_id); // get required parsed data $slider_setting = $parser->get_slider_setting(); $slides = $parser->get_slides(); $slider_custom_styles = $parser->get_styles(); $fields = array('title' => $slider_setting['title'], 'type' => $slider_setting['slider_type'], 'slides_num' => count($slides), 'params' => $msp_data, 'custom_styles' => $slider_custom_styles, 'custom_fonts' => $slider_setting['gfonts'], 'status' => 'published'); // store slider data in database $is_saved = $mspdb->update_slider($slider_id, $fields); msp_save_custom_styles(); // flush slider cache if slider cache is enabled msp_flush_slider_cache($slider_id); // create and output the response if (isset($is_saved)) { $response = json_encode(array('success' => true, 'type' => 'save', 'message' => __("Saved Successfully.", 'master-slider'))); } else { $response = json_encode(array('success' => true, 'type' => 'save', 'message' => __("No Data Recieved.", 'master-slider'))); } echo $response; exit; // IMPORTANT }
<?php // define( 'IFRAME_REQUEST', true ); echo '<div id="ms-preview-wrapper">'; if (isset($_REQUEST['slider_params']) && !empty($_REQUEST['slider_params'])) { $slider_params = $_REQUEST['slider_params']; $slider_shortcodes = msp_panel_data_2_ms_slider_shortcode($slider_params); echo do_shortcode($slider_shortcodes); // print slider custom css inline in live preview $parser = msp_get_parser(); $parser->set_data($slider_params); $slider_custom_css = $parser->get_styles(); printf("<!-- Custom slider styles -->\n<style>%s</style>", $slider_custom_css); } elseif (isset($_REQUEST['slider_id']) && !empty($_REQUEST['slider_id'])) { $slider_id = $_REQUEST['slider_id']; $slider_shortcodes = msp_get_ms_slider_shortcode_by_slider_id($slider_id); echo do_shortcode($slider_shortcodes); // print slider custom css inline in live preview printf("<!-- Custom slider styles -->\n<style>%s</style>", msp_get_slider_custom_css($slider_id)); } else { _e('Not found.', 'master-slider'); } echo "</div>\n"; if (isset($_REQUEST['strip_wp'])) { ?> <style> #adminmenuwrap, #wpadminbar, #adminmenuback, #screen-meta, #screen-meta-links,
public function get_ms_layer_shortcode($layer) { if (!isset($layer) || empty($layer)) { return ''; } $shortcode_name = 'ms_layer'; $attrs = ''; foreach ($layer as $attr => $attr_value) { if ('content' == $attr) { continue; } if ('parallax' == $attr && 'off' == $this->parsed_slider_data['setting']['parallax_mode']) { continue; } // users can add {{original-image}} and {{slide-image}} in layer link to link layer to current slide image if ('link' == $attr) { if (in_array($this->parsed_slider_data['setting']['slider_type'], array('post', 'wc-product'))) { $attr_value = preg_replace_callback('/{{[\\w-]+}}/', array($this, 'do_template_tag'), $attr_value); } elseif ('{{slide-image-url}}' == $attr_value) { $factory = msp_get_parser(); $slide = $factory->get_parent_of_layer($layer['id']); $attr_value = msp_get_the_absolute_media_url($slide['src_full']); } } $attrs .= sprintf('%s="%s" ', $attr, esc_attr($attr_value)); } $content = $layer['content']; if (in_array($this->parsed_slider_data['setting']['slider_type'], array('post', 'wc-product'))) { $content = preg_replace_callback('/{{[\\w-]+}}/', array($this, 'do_template_tag'), $content); } return sprintf('[%1$s %2$s]%4$s%3$s[/%1$s]%4$s', $shortcode_name, $attrs, $content, "\n"); }
/** * Update custom_css, custom_fonts and slide num fields in sliders table * * @param int $slider_id the slider id that is going to be updated * @return int|false The number of rows updated, or false on error. */ function msp_update_slider_custom_css_and_fonts($slider_id) { if (!isset($slider_id) || !is_numeric($slider_id)) { return false; } // get database tool global $mspdb; $slider_params = $mspdb->get_slider_field_val($slider_id, 'params'); if (!$slider_params) { return false; } // load and get parser and start parsing data $parser = msp_get_parser(); $parser->set_data($slider_params, $slider_id); // get required parsed data $slider_setting = $parser->get_slider_setting(); $slides = $parser->get_slides(); $slider_custom_styles = $parser->get_styles(); $fields = array('slides_num' => count($slides), 'custom_styles' => $slider_custom_styles, 'custom_fonts' => $slider_setting['gfonts']); msp_save_custom_styles(); $mspdb->update_slider($slider_id, $fields); }
/** * Extract images from slider data and add them to image_import_queue list * * @param string $slider_params the slider params * @return void */ public function extract_slider_images($slider_params) { $parser = msp_get_parser(); $parser->set_data($slider_params); $results = $parser->get_results(); // collect slider background image $this->image_import_queue[] = $results['setting']['bg_image']; if (isset($results['setting']['ps_slide_bg'])) { $this->image_import_queue[] = $results['setting']['ps_slide_bg']; } // collect layer's images if (isset($results['layers'])) { foreach ($results['layers'] as $layer) { $this->image_import_queue[] = $layer['src']; } } // collect slide's images if (isset($results['slides'])) { foreach ($results['slides'] as $slide) { // skip if current slide is 'overlay' slide not 'standard' slide if (empty($slide['src'])) { continue; } $this->image_import_queue[] = $slide['src']; $this->image_import_queue[] = $slide['thumb']; } } $this->image_import_queue = apply_filters('masterslider_extract_slider_images_to_import', $this->image_import_queue, $results); }
/** * Extract images from slider data and add them to image_import_queue list * @param string $slider_params the slider params * @return void */ public function extract_slider_images($slider_params) { $parser = msp_get_parser(); $parser->set_data($slider_params); $results = $parser->get_results(); // collect slider background image $this->image_import_queue[] = $results['setting']['bg_image']; if (isset($results['setting']['ps_slide_bg'])) { $this->image_import_queue[] = $results['setting']['ps_slide_bg']; } // collect slide's images if (isset($results['slides'])) { foreach ($results['slides'] as $slide) { $this->image_import_queue[] = $slide['src']; $this->image_import_queue[] = $slide['thumb']; } } $this->image_import_queue = apply_filters('masterslider_extract_slider_images_to_import', $this->image_import_queue, $results); }
function get_custom_msslider($atts) { $upload_dir = wp_upload_dir(); $slider_id = $atts['id']; $ms_db = new MSP_DB(); $slider = $ms_db->get_slider($slider_id); $parser = msp_get_parser(); $parser->set_data($slider['params'], $slider_id); $results = $parser->get_results(); $all_slides = $results['slides']; $str = '<ul id="foo5">'; for ($i = 0; $i <= count($all_slides) - 1; $i++) { $str .= ' <li><img class="img-responsive" src="' . $upload_dir['baseurl'] . $all_slides[$i]['src'] . '"></li>'; } $str .= '</ul>'; echo $str; }