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)); } }
/** * Run a series of checks to inform the user about incompatibilities, missing option fields, missing license keys for updates and suggested addons * * @since 0.8.6 */ function lasso_preflight_check() { $notices = array(); $article_object = lasso_editor_get_option('article_class', 'lasso_editor'); $theme_name = wp_get_theme()->get('Name'); $theme_class = lasso_get_supported_theme_class(); $license = get_option('lasso_license_key'); $status = get_option('lasso_license_status'); // if the required CSS class has not been saved and we're not a supported theme if (empty($article_object) && false == $theme_class) { // we dont automatically support this theme so show them otherwise $notices[] = sprintf('<li class="error"> <h3>' . __('Article CSS Class Needed!', 'lasso') . '</h3> <p>' . __('Before using Editus,', 'lasso') . ' <a href="%s">' . __('enter and save', 'lasso') . '</a> ' . __('the CSS class of the container that holds your post and page content. You can <a href="https://dl.dropboxusercontent.com/u/5594632/lasso-media/doc-movies/using-inspector-lasso.gif" target="_blank">use a tool like inspector</a> in Chrome or Firefox to find this CSS class, or ', 'lasso') . ' <a href="mailto:help@lasso.is">' . __('email us.', 'lasso') . '</a> ' . __('with a link to a public URL with the theme and we\'ll find it for you.', 'lasso') . '</p> </li>', admin_url('admin.php?page=lasso-editor-settings')); } // WP REST API not active if (!function_exists('json_get_url_prefix')) { $notices[] = '<li class="info"><h3>WP REST API not Activated!</h3> <p>' . __('Just a heads up that the WP REST API isn\'t activated. This is required to list the posts and pages on the front-end. It is required until WordPress officially merges the REST API into core sometime during 2015.', 'lasso') . '</p> </li>'; } // aesop story engine isnt active if (!class_exists('Aesop_Core')) { $notices[] = sprintf('<li class="info"><h3>Aesop Story Engine not Activated!</h3> <p>' . __('Just a heads up that ', 'lasso') . '<a href="%s" target="_blank ">' . __('Aesop Story Engine', 'lasso') . '</a> ' . __('isn\'t activated. It\'s not required to use Editus, but you won\'t get the cool drag and drop components without it activated. It\'s free!', 'lasso') . '</p> </li>', admin_url('plugin-install.php?tab=search&s=aesop+story+engine')); } // we dont really get along with wp side comments because of the section ids that get applied dynamically. since we save our html, it'll get saved along with the post as HTML if (class_exists('WP_Side_Comments')) { $notices[] = '<li class="error"><h3>' . __('WP Side Comments Compatibility Warning!', 'lasso') . '</h3> <p>' . __('Since Editus saves the HTML of a post, this may cause undesired issues. We\'re working to resolve incompatibilities faster than a jack rabbit in a hot greasy griddle in the middle of August.', 'lasso') . '</p> </li>'; } // if the license key isnt activated if (empty($license)) { $notices[] = '<li class="info"><h3>' . __('License Key Not Activated', 'lasso') . '</h3> <p>' . __('Just a heads up, your license key isn\'t activated. Enter your license key into the License tab on the left in order to receive plugin update notifications.', 'lasso') . '</p> </li>'; } if (!empty($license) && 'invalid' == $status) { $notices[] = '<li class="error"><h3>' . __('License Key Invalid', 'lasso') . '</h3> <p>' . __('The license key that you entered is ', 'lasso') . '<strong>' . __('invalid', 'lasso') . '</strong>' . __('. It may have been entered incorreclty, or may have expired.', 'lasso') . '</p> </li>'; } return apply_filters('lasso_preflight_notices', $notices); }
/** * Draw the main toolbar used to edit the text * * @since 1.0 */ function lasso_editor_text_toolbar() { ob_start(); if (!lasso_user_can()) { return; } // check for lasso story engine and add a class doniting this $ase_status = class_exists('Aesop_Core') || defined('LASSO_CUSTOM') ? 'ase-active' : 'ase-not-active'; // let users add custom css classes $custom_classes = apply_filters('lasso_toolbar_classes', ''); // are toolbar headings enabled $toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor'); $toolbar_class = $toolbar_headings ? 'toolbar-extended' : false; ?> <div class="lasso--toolbar_wrap lasso-editor-controls--wrap <?php echo $toolbar_class . ' ' . $ase_status . ' ' . sanitize_html_class($custom_classes); ?> "> <ul class="lasso--toolbar__inner lasso-editor-controls"> <?php do_action('lasso_toolbar_components_before'); ?> <li id="lasso-toolbar--bold" title="<?php esc_attr_e('Bold', 'lasso'); ?> "></li> <li id="lasso-toolbar--underline" title="<?php esc_attr_e('Underline', 'lasso'); ?> "></li> <li id="lasso-toolbar--italic" title="<?php esc_attr_e('Italicize', 'lasso'); ?> "></li> <li id="lasso-toolbar--strike" title="<?php esc_attr_e('Strikethrough', 'lasso'); ?> "></li> <?php if ($toolbar_headings) { ?> <li id="lasso-toolbar--h2" title="<?php esc_attr_e('H2 Heading', 'lasso'); ?> "></li> <li id="lasso-toolbar--h3" title="<?php esc_attr_e('H3 Heading', 'lasso'); ?> "></li> <?php } ?> <li id="lasso-toolbar--link" title="<?php esc_attr_e('Anchor Link', 'lasso'); ?> "> <div id="lasso-toolbar--link__wrap"> <div id="lasso-toolbar--link__inner" contenteditable="true" placeholder="<?php esc_attr_e('http://url.com', 'lasso'); ?> "></div> <a href="#" title="<?php esc_attr_e('Create Link', 'lasso'); ?> " class="lasso-toolbar--link__control" id="lasso-toolbar--link__create" ></a> </div> </li> <?php do_action('lasso_toolbar_components_after'); ?> <li id="lasso-toolbar--html" title="<?php esc_attr_e('Insert HTML', 'lasso'); ?> "> <div id="lasso-toolbar--html__wrap"> <div id="lasso-toolbar--html__inner" contenteditable="true" placeholder="<?php esc_attr_e('Enter HTML to insert', 'lasso'); ?> "></div> <div id="lasso-toolbar--html__footer"> <ul class="lasso-toolbar--html-snips"> <?php if (!$toolbar_headings) { ?> <li id="lasso-html--h2" title="<?php esc_attr_e('H2 Heading', 'lasso'); ?> "> <li id="lasso-html--h3" title="<?php esc_attr_e('H3 Heading', 'lasso'); ?> "> <?php } ?> <li id="lasso-html--ul" title="<?php esc_attr_e('Unordered List', 'lasso'); ?> "> <li id="lasso-html--ol" title="<?php esc_attr_e('Ordered List', 'lasso'); ?> "> </ul> <a class="lasso-toolbar--html__control lasso-toolbar--html__cancel" href="#"><?php _e('Cancel', 'lasso'); ?> </a> <a href="#" title="<?php esc_attr_e('Insert HTML', 'lasso'); ?> " class="lasso-toolbar--html__control" id="lasso-toolbar--html__insert" ><?php _e('Insert', 'lasso'); ?> </a> </div> </div> </li> <li id="lasso-toolbar--components" title="<?php esc_attr_e('Insert Component', 'lasso'); ?> "> <ul id="lasso-toolbar--components__list"> <?php if ('ase-active' == $ase_status) { ?> <li data-type="image" title="<?php esc_attr_e('Image', 'lasso'); ?> " class="lasso-toolbar--component__image"></li> <li data-type="character" title="<?php esc_attr_e('Character', 'lasso'); ?> " class="lasso-toolbar--component__character"></li> <li data-type="quote" title="<?php esc_attr_e('Quote', 'lasso'); ?> " class="lasso-toolbar--component__quote"></li> <li data-type="content" title="<?php esc_attr_e('Content', 'lasso'); ?> " class="lasso-toolbar--component__content"></li> <li data-type="chapter" title="<?php esc_attr_e('Chapter', 'lasso'); ?> " class="lasso-toolbar--component__chapter"></li> <li data-type="parallax" title="<?php esc_attr_e('Parallax', 'lasso'); ?> " class="lasso-toolbar--component__parallax"></li> <li data-type="audio" title="<?php esc_attr_e('Audio', 'lasso'); ?> " class="lasso-toolbar--component__audio"></li> <li data-type="video" title="<?php esc_attr_e('Video', 'lasso'); ?> " class="lasso-toolbar--component__video"></li> <li data-type="map" title="<?php esc_attr_e('Map', 'lasso'); ?> " class="lasso-toolbar--component__map"></li> <li data-type="timeline_stop" title="<?php esc_attr_e('Timeline', 'lasso'); ?> " class="lasso-toolbar--component__timeline"></li> <li data-type="document" title="<?php esc_attr_e('Document', 'lasso'); ?> " class="lasso-toolbar--component__document"></li> <li data-type="collection" title="<?php esc_attr_e('Collection', 'lasso'); ?> " class="lasso-toolbar--component__collection"></li> <li data-type="gallery" title="<?php esc_attr_e('Gallery', 'lasso'); ?> " class="lasso-toolbar--component__gallery"></li> <?php } else { ?> <li data-type="wpimg" title="<?php esc_attr_e('WordPress Image', 'lasso'); ?> " class="image lasso-toolbar--component__image"></li> <li data-type="wpquote" title="<?php esc_attr_e('WordPress Quote', 'lasso'); ?> " class="quote lasso-toolbar--component__quote"></li> <?php } ?> <?php do_action('lasso_toolbar_components'); ?> </ul> </li> </ul> </div> <?php return ob_get_clean(); }
/** * Check if saving post is disabled. * * @since 0.9.2 * * @access protected * * @return bool */ protected function save_to_post_disables() { $save_to_post_disabled = lasso_editor_get_option('post_save_disabled', 'lasso_editor'); return $save_to_post_disabled; }
/** * Draw the settings form * * @since 1.0 */ function lasso_editor_settings_form() { if (!is_user_logged_in()) { return; } $article_object = lasso_editor_get_option('article_class', 'lasso_editor'); $featImgClass = lasso_editor_get_option('featimg_class', 'lasso_editor'); $titleClass = lasso_editor_get_option('title_class', 'lasso_editor'); $post_new_disabled = lasso_editor_get_option('post_adding_disabled', 'lasso_editor'); $save_to_post_disabled = lasso_editor_get_option('post_save_disabled', 'lasso_editor'); $post_settings_disabled = lasso_editor_get_option('post_settings_disabled', 'lasso_editor'); $shortcodify_disabled = lasso_editor_get_option('shortcodify_disabled', 'lasso_editor'); $toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor'); $objectsNoSave = lasso_editor_get_option('dont_save', 'lasso_editor'); ?> <div class="wrap"> <h2><?php _e('Lasso Settings', 'lasso'); ?> </h2> <form id="lasso-editor-settings-form" class="lasso--form-settings" method="post" enctype="multipart/form-data"> <?php do_action('lasso_settings_before'); ?> <div class="lasso-editor-settings--option-wrap"> <div class="lasso-editor-settings--option-inner"> <label><?php _e('Article Class', 'lasso'); ?> </label> <span class="lasso--setting-description"><?php _e('Provide the CSS class (including the preceding dot) of container that holds the post. This should be the first parent container class that holds the_content.', 'lasso'); ?> </span> <input required type="text" name="lasso_editor[article_class]" id="lasso_editor[article_class]" value="<?php echo esc_attr($article_object); ?> " placeholder=".entry-content"> </div> </div> <div class="lasso-editor-settings--option-wrap"> <div class="lasso-editor-settings--option-inner"> <label><?php _e('Featured Image Class', 'lasso'); ?> </label> <span class="lasso--setting-description"><?php _e('Provide the CSS class that uses a featured image as a background image. This currently only supports themes that have the featured image set as background image.', 'lasso'); ?> </span> <input type="text" name="lasso_editor[featimg_class]" id="lasso_editor[featimg_class]" value="<?php echo esc_attr($featImgClass); ?> " placeholder=".entry-content"> </div> </div> <div class="lasso-editor-settings--option-wrap"> <div class="lasso-editor-settings--option-inner"> <label><?php _e('Article Title Class', 'lasso'); ?> </label> <span class="lasso--setting-description"><?php _e('Provide the CSS class for the post title. This will enable you to update the title of the post by clicking and typing.', 'lasso'); ?> </span> <input type="text" name="lasso_editor[title_class]" id="lasso_editor[title_class]" value="<?php echo esc_attr($titleClass); ?> " placeholder=".entry-content"> </div> </div> <!-- Advanced --> <div class="lasso-editor-settings--option-wrap"> <div class="lasso-editor-settings--option-inner"> <label><?php _e('Ignored Items to Save', 'lasso'); ?> </label> <span class="lasso--setting-description"><?php _e('If your post container holds additional markup, list the css class names (comma separated, including the dot) of those items. When you enter the editor, Lasso will remove (NOT delete) these items so that it does not save them as HTML.', 'lasso'); ?> </span> <textarea name="lasso_editor[dont_save]" id="lasso_editor[dont_save]" placeholder=".classname, .another-class"><?php echo esc_attr($objectsNoSave); ?> </textarea> </div> </div> <div class="lasso-editor-settings--option-wrap"> <div class="lasso-editor-settings--option-inner"> <input type="checkbox" class="checkbox" name="lasso_editor[toolbar_headings]" id="lasso_editor[toolbar_headings]" <?php echo checked($toolbar_headings, 'on'); ?> > <label for="lasso_editor[toolbar_headings]"><?php _e('Enable Toolbar Headings', 'lasso'); ?> </label> <span class="lasso--setting-description"><?php _e('By default the H2 and H3 options for headings are in the insert HTML area. You may prefer those headings to act just like the underline, and strikethrough, so toggling this will add them to the toolbar.', 'lasso'); ?> </span> </div> </div> <div class="lasso-editor-settings--option-wrap"> <div class="lasso-editor-settings--option-inner"> <input type="checkbox" class="checkbox" name="lasso_editor[post_save_disabled]" id="lasso_editor[post_save_disabled]" <?php echo checked($save_to_post_disabled, 'on'); ?> > <label for="lasso_editor[post_save_disabled]"><?php _e('Disable Post Saving', 'lasso'); ?> </label> <span class="lasso--setting-description"><?php _e('By default the editor will update the database with the post or page it is being used on. Check this box to disable this. If you check this box, it is assumed that you will be using the provided filters to save your own content.', 'lasso'); ?> </span> </div> </div> <div class="lasso-editor-settings--option-wrap"> <div class="lasso-editor-settings--option-inner"> <input type="checkbox" class="checkbox" name="lasso_editor[post_settings_disabled]" id="lasso_editor[post_settings_disabled]" <?php echo checked($post_settings_disabled, 'on'); ?> > <label for="lasso_editor[post_settings_disabled]"> <?php _e('Disable Post Settings', 'lasso'); ?> </label> <span class="lasso--setting-description"><?php _e('Check this to disable users from being able to edit post settings from the front-end.', 'lasso'); ?> </span> </div> </div> <div class="lasso-editor-settings--option-wrap"> <div class="lasso-editor-settings--option-inner"> <input type="checkbox" class="checkbox" name="lasso_editor[post_adding_disabled]" id="lasso_editor[post_adding_disabled]" <?php echo checked($post_new_disabled, 'on'); ?> > <label for="lasso_editor[post_adding_disabled]"><?php _e('Disable Post Adding', 'lasso'); ?> </label> <span class="lasso--setting-description"><?php _e('Check this box to disable users from being able to add new posts from the front-end.', 'lasso'); ?> </span> </div> </div> <div class="lasso-editor-settings--option-wrap last"> <div class="lasso-editor-settings--option-inner"> <input type="checkbox" class="checkbox" name="lasso_editor[shortcodify_disabled]" id="lasso_editor[shortcodify_disabled]" <?php echo checked($shortcodify_disabled, 'on'); ?> > <label for="lasso_editor[shortcodify_disabled]"><?php _e('Disable Aesop Component Conversion', 'lasso'); ?> </label> <span class="lasso--setting-description"><?php _e('Check this box to disable the conversion process used on Aesop Story Engine components.', 'lasso'); ?> </span> </div> </div> <?php do_action('lasso_settings_after'); ?> <div class="lasso-editor-settings--submit"> <input type="hidden" name="action" value="lasso-editor-settings" /> <input type="submit" class="button-primary" value="<?php esc_attr_e('Save Settings', 'lasso'); ?> " /> <?php wp_nonce_field('nonce', 'lasso_editor_settings'); ?> </div> </form> </div><?php }