Example #1
0
 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));
     }
 }
Example #2
0
    /**
     * 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);
    }