/** * Creates a gallery * * @since 0.9.2 * * @param array $data Sanitized data to use for saving. * * @return array|bool On success an array containing "message" or on failure false. */ public function create($data) { //@todo adapt auth callbacks to work with args. if (!lasso_user_can('publish_posts')) { return false; } $gallery_ids = isset($data['gallery_ids']) ? $data['gallery_ids'] : false; // bail if no gallery ids if (empty($gallery_ids)) { return false; } $postid = isset($data['postid']) ? (int) $data['postid'] : false; $type = isset($data['gallery_type']) ? $data['gallery_type'] : false; // insert a new gallery $args = array('post_title' => $postid . '-' . rand(), 'post_status' => 'publish', 'post_type' => 'ai_galleries'); $postid = wp_insert_post(apply_filters('lasso_insert_gallery_args', $args)); // update gallery ids if ($gallery_ids) { update_post_meta($postid, '_ase_gallery_images', $gallery_ids); } // update the gallery type if (!empty($type)) { update_post_meta($postid, 'aesop_gallery_type', $type); } do_action('lasso_gallery_published', $postid, $gallery_ids, get_current_user_ID()); return array('message' => 'gallery-created'); }
/** * * Components are shortcodes * * */ function shortcode($atts, $content = null) { $defaults = array('icon' => 'dashicons dashicons-edit', 'icon_color' => '', 'color' => '#eeeeee', 'title' => '', 'text' => '', 'image' => '', 'link' => '', 'link_text' => '', 'timestamp' => ''); $atts = shortcode_atts($defaults, $atts); // account for multiple instances of this component static $instance = 0; $instance++; $unique = sprintf('timeline-shortcode-%s-%s', get_the_ID(), $instance); // example of getting an option value //$beta = $atts['beta']; $icon = $atts['icon']; $icon_color = $atts['icon_color']; $color = $atts['color']; $title = $atts['title']; $text = $atts['text']; $image = $atts['image']; $link = $atts['link']; $link_text = $atts['link_text']; $timestamp = $atts['timestamp']; $has_image = '' != $image ? 'has-image' : ''; $no_link = '' == $link ? 'no-link' : ''; // if lasso is active we need to map the sc atts as data-attributes if (class_exists('lasso_autoloader') && (function_exists('lasso_user_can') && lasso_user_can())) { $options = function_exists('aesop_component_data_atts') ? aesop_component_data_atts('timeline', $unique, $atts) : false; } else { $options = false; } $out = sprintf('' . '<div id="%s" class="aesop-component aesop-component-timeline-block" %s>' . '<div class="aesop-component-timeline-icon" style="background-color: %s;">' . '<i class="%s" style="color: %s;"></i>' . '</div>' . '<div class="aesop-component-timeline-content %s %s">' . '<div class="aesop-component-timeline-image" style="background-image: url(\'%s\');"></div>' . '<h2 class="aesop-component-timeline-title">%s</h2>' . '<p class="aesop-component-timeline-text">%s</p>' . '<a class="aesop-component-timeline-link" href="%s">%s</a>' . '<span class="aesop-component-timeline-timestamp">%s</span>' . '</div>' . '</div>', $unique, $options, $color, $icon, $icon_color, $has_image, $no_link, $image, $title, $text, $link, $link_text, $timestamp); return $out; }
/** * Process the post delete * * @since 1.0 */ public function post($data) { $postid = isset($data['postid']) ? $data['postid'] : false; // bail out if teh current user can't publish posts if (!lasso_user_can('delete_post', $postid)) { return; } $args = array('ID' => (int) $postid, 'post_status' => 'trash'); wp_update_post(apply_filters('lasso_object_deleted_args', $args)); do_action('lasso_object_deleted', $postid, get_current_user_ID()); return true; }
function lasso_backbone_templates() { $can_delete = lasso_user_can('delete_others_posts'); $can_delete_class = $can_delete ? false : 'no-delete'; // only run on posts and pages if user is logged in if (is_user_logged_in() && lasso_user_can('edit_posts')) { ?> <script type="text/html" id="lasso-tmpl--post"> <li> <a href="<%= post.link %>" class="lasso--post-list__item <?php echo $can_delete_class; ?> <%= post.status %>" data-postid="<%= post.ID %>" > <%= post.title %> <div class="lasso--post-list__controls"> <span title="<?php echo esc_attr_e('Edit Post', 'lasso'); ?> " id="lasso--post__edit"></span> <?php if ($can_delete) { ?> <span title="<?php echo esc_attr_e('Delete Post', 'lasso'); ?> " id="lasso--post__delete"></span> <?php } ?> </div> </a> </li> </script> <?php } }
public function scripts() { if (lasso_user_can('edit_posts')) { wp_enqueue_style('lasso-style', LASSO_URL . '/public/assets/css/lasso.css', LASSO_VERSION, true); wp_enqueue_script('jquery-ui-autocomplete'); wp_enqueue_script('jquery-ui-draggable'); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_script('jquery-ui-slider'); // media uploader wp_enqueue_media(); // url for json api $home_url = function_exists('json_get_url_prefix') ? json_get_url_prefix() : false; $article_object = lasso_editor_get_option('article_class', 'lasso_editor'); $article_object = empty($article_object) && lasso_get_supported_theme_class() ? lasso_get_supported_theme_class() : $article_object; $featImgClass = lasso_editor_get_option('featimg_class', 'lasso_editor'); $titleClass = lasso_editor_get_option('title_class', 'lasso_editor'); $toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor'); $objectsNoSave = lasso_editor_get_option('dont_save', 'lasso_editor'); // post id reference $postid = get_the_ID(); $strings = array('save' => __('Save', 'lasso'), 'saving' => __('Saving...', 'lasso'), 'saved' => __('Saved!', 'lasso'), 'adding' => __('Adding...', 'lasso'), 'added' => __('Added!', 'lasso'), 'loading' => __('Loading...', 'lasso'), 'loadMore' => __('Load More', 'lasso'), 'noPostsFound' => __('No more posts found', 'lasso'), 'galleryCreated' => __('Gallery Created!', 'lasso'), 'galleryUpdated' => __('Gallery Updated!', 'lasso'), 'justWrite' => __('Just write...', 'lasso'), 'chooseImage' => __('Choose an image', 'lasso'), 'updateImage' => __('Update Image', 'lasso'), 'insertImage' => __('Insert Image', 'lasso'), 'selectImage' => __('Select Image', 'lasso'), 'removeFeatImg' => __('Remove featured image?', 'lasso'), 'updateSelectedImg' => __('Update Selected Image', 'lasso'), 'chooseImages' => __('Choose images', 'lasso'), 'editImage' => __('Edit Image', 'lasso'), 'addImages' => __('Add Images', 'lasso'), 'addNewGallery' => __('Add New Gallery', 'lasso'), 'selectGallery' => __('Select Lasso Gallery Image', 'lasso'), 'useSelectedImages' => __('Use Selected Images', 'lasso'), 'publishPost' => __('Publish Post?', 'lasso'), 'publishYes' => __('Yes, publish it!', 'lasso'), 'deletePost' => __('Trash Post?', 'lasso'), 'deleteYes' => __('Yes, trash it!', 'lasso'), 'warning' => __('Oh snap!', 'laso'), 'cancelText' => __('O.K. got it!', 'lasso'), 'missingClass' => __('It looks like we are missing the Article CSS class. Lasso will not function correctly without this CSS class.', 'lasso'), 'missingConfirm' => __('Update Settings', 'lasso'), 'helperText' => __('one more letter', 'lasso'), 'editingBackup' => __('You are currently editing a backup copy of this post.')); $api_url = trailingslashit(home_url()) . 'lasso-internal-api'; $gallery_class = new gallery(); $gallery_nonce_action = $gallery_class->nonce_action; $gallery_nonce = wp_create_nonce($gallery_nonce_action); // localized objects $objects = array('ajaxurl' => esc_url($api_url), 'editor' => 'lasso--content', 'article_object' => $article_object, 'featImgClass' => $featImgClass, 'titleClass' => $titleClass, 'strings' => $strings, 'settingsLink' => function_exists('is_multisite') && is_multisite() ? network_admin_url('settings.php?page=lasso-editor') : admin_url('admin.php?page=lasso-editor-settings'), 'post_status' => get_post_status($postid), 'postid' => $postid, 'permalink' => get_permalink(), 'edit_others_pages' => current_user_can('edit_others_pages') ? 'true' : 'false', 'edit_others_posts' => current_user_can('edit_others_posts') ? 'true' : 'false', 'userCanEdit' => current_user_can('edit_post', $postid), 'can_publish_posts' => current_user_can('publish_posts'), 'can_publish_pages' => current_user_can('publish_pages'), 'author' => is_user_logged_in() ? get_current_user_ID() : false, 'nonce' => wp_create_nonce('lasso_editor'), 'handle' => lasso_editor_settings_toolbar(), 'toolbar' => lasso_editor_text_toolbar(), 'toolbarHeadings' => $toolbar_headings, 'component_modal' => lasso_editor_component_modal(), 'component_sidebar' => lasso_editor_component_sidebar(), 'components' => lasso_editor_components(), 'wpImgEdit' => lasso_editor_wpimg_edit(), 'featImgControls' => lasso_editor_image_controls(), 'featImgNonce' => $gallery_nonce, 'getGallImgNonce' => $gallery_nonce, 'createGallNonce' => $gallery_nonce, 'swapGallNonce' => $gallery_nonce, 'titleNonce' => wp_create_nonce('lasso_update_title'), 'wpImgNonce' => wp_create_nonce('lasso_update_wpimg'), 'deletePost' => wp_create_nonce('lasso_delete_post'), 'searchPosts' => wp_create_nonce('lasso_search_posts'), 'component_options' => lasso_editor_options_blob(), 'newPostModal' => lasso_editor_newpost_modal(), 'allPostModal' => lasso_editor_allpost_modal(), 'mapFormFooter' => lasso_map_form_footer(), 'refreshRequired' => lasso_editor_refresh_message(), 'objectsNoSave' => $objectsNoSave, 'supportedNoSave' => lasso_supported_no_save(), 'postCategories' => lasso_get_objects('category'), 'postTags' => lasso_get_objects('tag'), 'noResultsDiv' => lasso_editor_empty_results(), 'noRevisionsDiv' => lasso_editor_empty_results('revision'), 'mapTileProvider' => function_exists('aesop_map_tile_provider') ? aesop_map_tile_provider($postid) : false, 'mapLocations' => get_post_meta($postid, 'ase_map_component_locations'), 'mapStart' => get_post_meta($postid, 'ase_map_component_start_point', true), 'mapZoom' => get_post_meta($postid, 'ase_map_component_zoom', true), 'revisionModal' => lasso_editor_revision_modal()); // wp api client wp_enqueue_script('wp-api-js', LASSO_URL . '/public/assets/js/source/util--wp-api.js', array('jquery', 'underscore', 'backbone'), LASSO_VERSION, true); $settings = array('root' => home_url($home_url), 'nonce' => wp_create_nonce('wp_json')); wp_localize_script('wp-api-js', 'WP_API_Settings', $settings); $postfix = defined('SCRIPT_DEBUG') && true === SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script('lasso', LASSO_URL . "/public/assets/js/lasso{$postfix}.js", array('jquery'), LASSO_VERSION, true); wp_localize_script('lasso', 'lasso_editor', apply_filters('lasso_localized_objects', $objects)); } }
/** * Build the gallery creation and management area shown in panel * * @since 1.0 */ function lasso_gallery_editor_module() { $galleries = lasso_editor_galleries_exist(); ob_start(); if ($galleries) { ?> <div class="ase-gallery-opts ase-gallery-opts--edit-gallery" > <div class="ase-gallery-opts--single lasso-option"> <label><?php _e('Manage Images', 'lasso'); ?> <a href="#" id="ase-gallery-add-image" class="lasso-editor-tiny-btn" title="<?php esc_attr_e('Add Images', 'lasso'); ?> "><i class="lasso-icon-pencil"></i></a> <?php if (lasso_user_can('publish_posts')) { ?> <a href="#" id="lasso--gallery__create" class="lasso-editor-tiny-btn" title="<?php esc_attr_e('Create Gallery', 'lasso'); ?> "><i class="lasso-icon-plus"></i></a> <?php } ?> </label> <small class="lasso-option-desc"><?php _e('Rearrange or edit the images in this gallery.', 'lasso'); ?> </small> <div id="lasso--gallery__images"><span class="lasso-icon-spinner6"></span></div> </div> </div> <?php } if (lasso_user_can('publish_posts')) { ?> <div class="ase-gallery-opts ase-gallery-opts--create-gallery" > <div class="ase-gallery-opts--single lasso-option"> <label><?php _e('Create a Gallery', 'lasso'); ?> </label> <small class="lasso-option-desc"><?php _e('Select images to create a gallery.', 'lasso'); ?> </small> <a href="#" class="editor-btn-secondary" id="lasso--gallery__selectImages"><?php _e('Select Images', 'lasso'); ?> </a> <div id="ase-gallery-images"></div> <a style="display:none;" class="editor-btn-secondary" data-post-title="<?php echo esc_attr(strtolower(the_title_attribute())); ?> " id="lasso--gallery__save" href="#"><?php _e('Create Gallery', 'lasso'); ?> </a> </div> </div> <?php } ?> <!-- Gallery Layout/Type Chooser --> <div class="ase-gallery-opts ase-gallery-opts--type" > <div data-option="gallery-type" class="ase-gallery-opts--single lasso-option"> <label><?php _e('Gallery Type', 'lasso'); ?> </label> <small class="lasso-option-desc"><?php _e('Select the type of gallery.', 'lasso'); ?> </small> <fieldset> <label for="lasso_gallery_type" class="ase-gallery-layout-label"><input class="lasso-generator-attr ase-gallery-type-radio" type="radio" name="lasso_gallery_type" value="grid"><?php _e('Grid', 'lasso'); ?> </label> <label for="lasso_gallery_type" class="ase-gallery-layout-label"><input class="lasso-generator-attr ase-gallery-type-radio" type="radio" name="lasso_gallery_type" value="thumbnail"><?php _e('Thumbnail', 'lasso'); ?> </label> <label for="lasso_gallery_type" class="ase-gallery-layout-label"><input class="lasso-generator-attr ase-gallery-type-radio" type="radio" name="lasso_gallery_type" value="sequence">Sequence</label> <label for="lasso_gallery_type" class="ase-gallery-layout-label"><input class="lasso-generator-attr ase-gallery-type-radio" type="radio" name="lasso_gallery_type" value="photoset"><?php _e('Photoset', 'lasso'); ?> </label> <label for="lasso_gallery_type" class="ase-gallery-layout-label"><input class="lasso-generator-attr ase-gallery-type-radio" type="radio" name="lasso_gallery_type" value="stacked"><?php _e('Parallax', 'lasso'); ?> </label> </fieldset> </div> </div> <!-- Conditionally Loaded Gallery Option - Grid Options --> <div class="ase-gallery-opts ase-gallery-opts--grid" style="display:none;"> <div data-option="itemwidth" class="ase-gallery-opts--single lasso-option"> <label for="lasso_grid_gallery_width"><?php _e('Grid Item Width', 'lasso'); ?> </label> <small class="lasso-option-desc"><?php _e('Adjust the width of the individual grid items, only if using Grid gallery style. Default is 400.', 'lasso'); ?> </small> <input type="text_small" class="lasso-generator-attr" name="lasso_grid_gallery_width" value=""> </div> </div> <!-- Conditionally Loaded Gallery Option - Thumb Options --> <div class="ase-gallery-opts ase-gallery-opts--thumb" style="display:none;"> <div data-option="transition" class="ase-gallery-opts--single lasso-option"> <label for="lasso_thumb_gallery_transition"><?php _e('Gallery Transition', 'lasso'); ?> </label> <small class="lasso-option-desc"><?php _e('Adjust the transition effect for the Thumbnail gallery. Default is slide.', 'lasso'); ?> </small> <select name="lasso_thumb_gallery_transition" class="lasso-generator-attr"> <option value="crossfade"><?php _e('Fade', 'lasso'); ?> </option> <option value="slide"><?php _e('Slide', 'lasso'); ?> </option> <option value="dissolve"><?php _e('Dissolve', 'lasso'); ?> </option> </select> </div> <div data-option="speed" class="ase-gallery-opts--single lasso-option"> <label for="lasso_thumb_gallery_transition_speed"><?php _e('Gallery Transition Speed', 'lasso'); ?> </label> <small class="lasso-option-desc"><?php _e('Activate slideshow by setting a speed for the transition.5000 = 5 seconds.', 'lasso'); ?> </small> <input type="text" class="lasso-generator-attr" name="lasso_thumb_gallery_transition_speed" value=""> </div> <div data-option="hide-thumbs" class="ase-gallery-opts--single lasso-option"> <input class="lasso-generator-attr" type="checkbox" name="lasso_thumb_gallery_hide_thumbs"> <label for="lasso_thumb_gallery_hide_thumbs"><?php _e('Hide Gallery Thumbnails', 'lasso'); ?> </label> </div> </div> <!-- Conditionally Loaded Gallery Option - Photoset Options --> <div class="ase-gallery-opts ase-gallery-opts--photoset" style="display:none;"> <div data-option="pslayout" class="ase-gallery-opts--single lasso-option"> <label for="lasso-photoset-gallery-layout"><?php _e('Gallery Layout', 'lasso'); ?> </label> <small class="lasso-option-desc"><?php _e('Let\'s say you have 4 images in this gallery. If you enter 121 you will have one image on the top row, two images on the second row, and one image on the third row.', 'lasso'); ?> </small> <input type="text" class="lasso-generator-attr" name="lasso_photoset_gallery_layout" value=""> </div> <div data-option="pslightbox" class="ase-gallery-opts--single lasso-option"> <input type="checkbox" class="lasso-generator-attr" name="lasso_photoset_gallery_lightbox"> <label for="lasso_photoset_gallery_lightbox"><?php _e('Enable Lightbox', 'lasso'); ?> </label> </div> </div> <!-- Global Gallery Options --> <div class="ase-gallery-opts ase-gallery-opts--global"> <div data-option="width" class="ase-gallery-opts--single lasso-option"> <label for="lasso_gallery_width"><?php _e('Main Gallery Width', 'lasso'); ?> </label> <small class="lasso-option-desc"><?php _e('Adjust the overall width of the grid/thumbnail gallery. Acceptable values include 500px or 50%.', 'lasso'); ?> </small> <input type="text_small" class="lasso-generator-attr" name="lasso_gallery_width" value=""> </div> <div data-option="caption" class="ase-gallery-opts--single lasso-option"> <label for="lasso_gallery_caption"><?php _e('Gallery Caption', 'lasso'); ?> </label> <small class="lasso-option-desc"><?php _e('Add an optional caption for the gallery.', 'lasso'); ?> </small> <textarea name="lasso_gallery_caption" class="lasso-generator-attr"></textarea> </div> </div> <input type="hidden" id="ase_gallery_ids" name="ase_gallery_ids" value=""> <input type="hidden" id="ase_gallery_type" name="ase_gallery_type" value=""> <?php return ob_get_clean(); }
/** * Draw the modal used to house the walk through * @since 0.6 */ public function draw_tour() { $tour_hidden = get_user_meta(get_current_user_ID(), 'lasso_hide_tour', true); if (lasso_user_can() && !$tour_hidden) { global $post; $nonce = wp_create_nonce('lasso-editor-tour'); // let users add custom css classes $custom_classes = apply_filters('lasso_modal_tour_classes', ''); ?> <div id="lasso--tour__modal" class="lasso--modal lasso--tour__modal lasso--modal__checkbox <?php echo sanitize_html_class($custom_classes); ?> "> <script> jQuery(window).ready(function($){ $('body').addClass('lasso-modal-open'); $('.lasso--loading').remove(); $('#lasso--tour__slides').hide().fadeIn() $('#lasso--tour__slides').unslider({ dots: true, delay:7000 }); }); </script> <div class="lasso--modal__inner"> <?php echo self::tour_slides(); ?> <div class="lasso--postsettings__footer"> <div class="lasso--postsettings__option"> <label for="hide_tour" class="checkbox-control checkbox"> <input type="checkbox" id="hide_tour" name="hide_tour" <?php checked($tour_hidden, 1); ?> > <span class="control-indicator"></span> <?php _e('Don\'t show this again', 'lasso'); ?> </label> </div> <input type="submit" value="<?php _e('Okay, got it!', 'lasso'); ?> " data-nonce="<?php echo $nonce; ?> " > </div> </div> </div> <div id="lasso--modal__overlay"></div> <?php } }
function lasso_editor_wpimg_edit() { ob_start(); if (!lasso_user_can()) { return; } // let users add custom css classes $custom_classes = apply_filters('lasso_wpimg_classes', ''); ?> <ul class="lasso-component--controls <?php echo sanitize_html_class($custom_classes); ?> " contenteditable="false"> <li class="lasso-drag" title="<?php esc_attr_e('Move', 'lasso'); ?> "></li> <li id="lasso--wpimg-edit" class="lasso-settings" title="<?php esc_attr_e('Settings', 'lasso'); ?> "></li> <li class="lasso-clone" title="<?php esc_attr_e('Clone', 'lasso'); ?> "></li> <li class="lasso-delete" title="<?php esc_attr_e('Delete', 'lasso'); ?> "></li> </ul> <?php return ob_get_clean(); }