Example #1
0
function twym_remove_editor_styles()
{
    $settings = get_option('twym_settings');
    $theme_styles = isset($settings['theme_styles']) ? '1' : false;
    if ('1' === $theme_styles) {
        return;
    }
    remove_editor_styles();
}
    /**
     * Serves the app's base HTML, which in turns calls the load script.
     *
     * @since 4.2.0
     * @access public
     *
     * @global WP_Locale $wp_locale
     * @global string    $wp_version
     * @global bool      $is_IE
     */
    public function html()
    {
        global $wp_locale, $wp_version;
        // Get data, new (POST) and old (GET).
        $data = $this->merge_or_fetch_data();
        $post_title = $this->get_suggested_title($data);
        $post_content = $this->get_suggested_content($data);
        // Get site settings array/data.
        $site_settings = $this->site_settings();
        // Pass the images and embeds
        $images = $this->get_images($data);
        $embeds = $this->get_embeds($data);
        $site_data = array('v' => !empty($data['v']) ? $data['v'] : '', 'u' => !empty($data['u']) ? $data['u'] : '', 'hasData' => !empty($data));
        if (!empty($images)) {
            $site_data['_images'] = $images;
        }
        if (!empty($embeds)) {
            $site_data['_embeds'] = $embeds;
        }
        // Add press-this-editor.css and remove theme's editor-style.css, if any.
        remove_editor_styles();
        add_filter('mce_css', array($this, 'add_editor_style'));
        if (!empty($GLOBALS['is_IE'])) {
            @header('X-UA-Compatible: IE=edge');
        }
        @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
        ?>
<!DOCTYPE html>
<!--[if IE 7]>         <html class="lt-ie9 lt-ie8" <?php 
        language_attributes();
        ?>
> <![endif]-->
<!--[if IE 8]>         <html class="lt-ie9" <?php 
        language_attributes();
        ?>
> <![endif]-->
<!--[if gt IE 8]><!--> <html <?php 
        language_attributes();
        ?>
> <!--<![endif]-->
<head>
	<meta http-equiv="Content-Type" content="<?php 
        echo esc_attr(get_bloginfo('html_type'));
        ?>
; charset=<?php 
        echo esc_attr(get_option('blog_charset'));
        ?>
" />
	<meta name="viewport" content="width=device-width">
	<title><?php 
        esc_html_e('Press This!');
        ?>
</title>

	<script>
		window.wpPressThisData   = <?php 
        echo wp_json_encode($site_data);
        ?>
;
		window.wpPressThisConfig = <?php 
        echo wp_json_encode($site_settings);
        ?>
;
	</script>

	<script type="text/javascript">
		var ajaxurl = '<?php 
        echo esc_js(admin_url('admin-ajax.php', 'relative'));
        ?>
',
			pagenow = 'press-this',
			typenow = 'post',
			adminpage = 'press-this-php',
			thousandsSeparator = '<?php 
        echo addslashes($wp_locale->number_format['thousands_sep']);
        ?>
',
			decimalPoint = '<?php 
        echo addslashes($wp_locale->number_format['decimal_point']);
        ?>
',
			isRtl = <?php 
        echo (int) is_rtl();
        ?>
;
	</script>

	<?php 
        /*
         * $post->ID is needed for the embed shortcode so we can show oEmbed previews in the editor.
         * Maybe find a way without it.
         */
        $post = get_default_post_to_edit('post', true);
        $post_ID = (int) $post->ID;
        wp_enqueue_media(array('post' => $post_ID));
        wp_enqueue_style('press-this');
        wp_enqueue_script('press-this');
        wp_enqueue_script('json2');
        wp_enqueue_script('editor');
        $supports_formats = false;
        $post_format = 0;
        if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) {
            $supports_formats = true;
            if (!($post_format = get_post_format($post_ID))) {
                $post_format = 0;
            }
        }
        /** This action is documented in wp-admin/admin-header.php */
        do_action('admin_enqueue_scripts', 'press-this.php');
        /** This action is documented in wp-admin/admin-header.php */
        do_action('admin_print_styles-press-this.php');
        /** This action is documented in wp-admin/admin-header.php */
        do_action('admin_print_styles');
        /** This action is documented in wp-admin/admin-header.php */
        do_action('admin_print_scripts-press-this.php');
        /** This action is documented in wp-admin/admin-header.php */
        do_action('admin_print_scripts');
        /** This action is documented in wp-admin/admin-header.php */
        do_action('admin_head-press-this.php');
        /** This action is documented in wp-admin/admin-header.php */
        do_action('admin_head');
        ?>
</head>
<?php 
        $admin_body_class = 'press-this';
        $admin_body_class .= is_rtl() ? ' rtl' : '';
        $admin_body_class .= ' branch-' . str_replace(array('.', ','), '-', floatval($wp_version));
        $admin_body_class .= ' version-' . str_replace('.', '-', preg_replace('/^([.0-9]+).*/', '$1', $wp_version));
        $admin_body_class .= ' admin-color-' . sanitize_html_class(get_user_option('admin_color'), 'fresh');
        $admin_body_class .= ' locale-' . sanitize_html_class(strtolower(str_replace('_', '-', get_locale())));
        /** This filter is documented in wp-admin/admin-header.php */
        $admin_body_classes = apply_filters('admin_body_class', '');
        ?>
<body class="wp-admin wp-core-ui <?php 
        echo $admin_body_classes . ' ' . $admin_body_class;
        ?>
">
	<div id="adminbar" class="adminbar">
		<h1 id="current-site" class="current-site">
			<a class="current-site-link" href="<?php 
        echo esc_url(home_url('/'));
        ?>
" target="_blank" rel="home">
				<span class="dashicons dashicons-wordpress"></span>
				<span class="current-site-name"><?php 
        bloginfo('name');
        ?>
</span>
			</a>
		</h1>
		<button type="button" class="options button-subtle closed">
			<span class="dashicons dashicons-tag on-closed"></span>
			<span class="screen-reader-text on-closed"><?php 
        _e('Show post options');
        ?>
</span>
			<span aria-hidden="true" class="on-open"><?php 
        _e('Done');
        ?>
</span>
			<span class="screen-reader-text on-open"><?php 
        _e('Hide post options');
        ?>
</span>
		</button>
	</div>

	<div id="scanbar" class="scan">
		<form method="GET">
			<label for="url-scan" class="screen-reader-text"><?php 
        _e('Scan site for content');
        ?>
</label>
			<input type="url" name="u" id="url-scan" class="scan-url" value="" placeholder="<?php 
        esc_attr_e('Enter a URL to scan');
        ?>
" />
			<input type="submit" name="url-scan-submit" id="url-scan-submit" class="scan-submit" value="<?php 
        esc_attr_e('Scan');
        ?>
" />
		</form>
	</div>

	<form id="pressthis-form" method="post" action="post.php" autocomplete="off">
		<input type="hidden" name="post_ID" id="post_ID" value="<?php 
        echo $post_ID;
        ?>
" />
		<input type="hidden" name="action" value="press-this-save-post" />
		<input type="hidden" name="post_status" id="post_status" value="draft" />
		<input type="hidden" name="wp-preview" id="wp-preview" value="" />
		<input type="hidden" name="post_title" id="post_title" value="" />
		<?php 
        wp_nonce_field('update-post_' . $post_ID, '_wpnonce', false);
        wp_nonce_field('add-category', '_ajax_nonce-add-category', false);
        ?>

	<div class="wrapper">
		<div class="editor-wrapper">
			<div class="alerts" role="alert" aria-live="assertive" aria-relevant="all" aria-atomic="true">
				<?php 
        if (isset($data['v']) && $this->version > $data['v']) {
            ?>
					<p class="alert is-notice">
						<?php 
            printf(__('You should upgrade <a href="%s" target="_blank">your bookmarklet</a> to the latest version!'), admin_url('tools.php'));
            ?>
					</p>
					<?php 
        }
        ?>
			</div>

			<div id="app-container" class="editor">
				<span id="title-container-label" class="post-title-placeholder" aria-hidden="true"><?php 
        _e('Post title');
        ?>
</span>
				<h2 id="title-container" class="post-title" contenteditable="true" spellcheck="true" aria-label="<?php 
        esc_attr_e('Post title');
        ?>
" tabindex="0"><?php 
        echo esc_html($post_title);
        ?>
</h2>

				<div class="media-list-container">
					<div class="media-list-inner-container">
						<h2 class="screen-reader-text"><?php 
        _e('Suggested media');
        ?>
</h2>
						<ul class="media-list"></ul>
					</div>
				</div>

				<?php 
        wp_editor($post_content, 'pressthis', array('drag_drop_upload' => true, 'editor_height' => 600, 'media_buttons' => false, 'textarea_name' => 'post_content', 'teeny' => true, 'tinymce' => array('resize' => false, 'wordpress_adv_hidden' => false, 'add_unload_trigger' => false, 'statusbar' => false, 'autoresize_min_height' => 600, 'wp_autoresize_on' => true, 'plugins' => 'lists,media,paste,tabfocus,fullscreen,wordpress,wpautoresize,wpeditimage,wpgallery,wplink,wpview', 'toolbar1' => 'bold,italic,bullist,numlist,blockquote,link,unlink', 'toolbar2' => 'undo,redo'), 'quicktags' => false));
        ?>
			</div>
		</div>

		<div class="options-panel-back is-hidden" tabindex="-1"></div>
		<div class="options-panel is-off-screen is-hidden" tabindex="-1">
			<div class="post-options">

				<?php 
        if ($supports_formats) {
            ?>
					<button type="button" class="button-reset post-option">
						<span class="dashicons dashicons-admin-post"></span>
						<span class="post-option-title"><?php 
            _ex('Format', 'post format');
            ?>
</span>
						<span class="post-option-contents" id="post-option-post-format"><?php 
            echo esc_html(get_post_format_string($post_format));
            ?>
</span>
						<span class="dashicons post-option-forward"></span>
					</button>
				<?php 
        }
        ?>

				<button type="button" class="button-reset post-option">
					<span class="dashicons dashicons-category"></span>
					<span class="post-option-title"><?php 
        _e('Categories');
        ?>
</span>
					<span class="dashicons post-option-forward"></span>
				</button>

				<button type="button" class="button-reset post-option">
					<span class="dashicons dashicons-tag"></span>
					<span class="post-option-title"><?php 
        _e('Tags');
        ?>
</span>
					<span class="dashicons post-option-forward"></span>
				</button>
			</div>

			<?php 
        if ($supports_formats) {
            ?>
				<div class="setting-modal is-off-screen is-hidden">
					<button type="button" class="button-reset modal-close">
						<span class="dashicons post-option-back"></span>
						<span class="setting-title" aria-hidden="true"><?php 
            _ex('Format', 'post format');
            ?>
</span>
						<span class="screen-reader-text"><?php 
            _e('Back to post options');
            ?>
</span>
					</button>
					<?php 
            $this->post_formats_html($post);
            ?>
				</div>
			<?php 
        }
        ?>

			<div class="setting-modal is-off-screen is-hidden">
				<button type="button" class="button-reset modal-close">
					<span class="dashicons post-option-back"></span>
					<span class="setting-title" aria-hidden="true"><?php 
        _e('Categories');
        ?>
</span>
					<span class="screen-reader-text"><?php 
        _e('Back to post options');
        ?>
</span>
				</button>
				<?php 
        $this->categories_html($post);
        ?>
			</div>

			<div class="setting-modal tags is-off-screen is-hidden">
				<button type="button" class="button-reset modal-close">
					<span class="dashicons post-option-back"></span>
					<span class="setting-title" aria-hidden="true"><?php 
        _e('Tags');
        ?>
</span>
					<span class="screen-reader-text"><?php 
        _e('Back to post options');
        ?>
</span>
				</button>
				<?php 
        $this->tags_html($post);
        ?>
			</div>
		</div><!-- .options-panel -->
	</div><!-- .wrapper -->

	<div class="press-this-actions">
		<div class="pressthis-media-buttons">
			<button type="button" class="insert-media button-subtle" data-editor="pressthis">
				<span class="dashicons dashicons-admin-media"></span>
				<span class="screen-reader-text"><?php 
        _e('Add Media');
        ?>
</span>
			</button>
		</div>
		<div class="post-actions">
			<span class="spinner">&nbsp;</span>
			<div class="split-button">
				<div class="split-button-head">
					<button type="button" class="publish-button split-button-primary"><?php 
        echo current_user_can('publish_posts') ? __('Publish') : __('Submit for Review');
        ?>
</button><button type="button" class="split-button-toggle" aria-haspopup="true" aria-expanded="false">
						<i class="dashicons dashicons-arrow-down-alt2"></i>
						<span class="screen-reader-text"><?php 
        _e('More actions');
        ?>
</span>
					</button>
				</div>
				<ul class="split-button-body">
					<li><button type="button" class="button-subtle draft-button split-button-option" aria-live="polite"><?php 
        _e('Save Draft');
        ?>
</button></li>
					<li><a href="<?php 
        echo esc_url(get_edit_post_link($post_ID));
        ?>
" class="edit-post-link split-button-option" target="_blank"><?php 
        _e('Standard Editor');
        ?>
</a></li>
					<li><button type="button" class="button-subtle preview-button split-button-option"><?php 
        _e('Preview');
        ?>
</button></li>
				</ul>
			</div>
		</div>
	</div>
	</form>

	<?php 
        /** This action is documented in wp-admin/admin-footer.php */
        do_action('admin_footer');
        /** This action is documented in wp-admin/admin-footer.php */
        do_action('admin_print_footer_scripts');
        /** This action is documented in wp-admin/admin-footer.php */
        do_action('admin_footer-press-this.php');
        ?>
</body>
</html>
<?php 
        die;
    }
Example #3
0
    /**
     * Serves the app's base HTML, which in turns calls the load.js
     *
     * @since 4.2
     */
    public function serve_app_html()
    {
        global $wp_locale;
        // Get data, new (POST) and old (GET)
        $data = $this->merge_or_fetch_data();
        // Get site settings array/data
        $site_settings = $this->site_settings();
        // Set the passed data
        $data['_version'] = $site_settings['version'];
        $data['_runtime_url'] = $site_settings['runtime_url'];
        $data['_ajax_url'] = $site_settings['ajax_url'];
        // Plugin only
        wp_register_script('press-this-app', plugin_dir_url(__FILE__) . 'js/app.js', array('jquery'), false, true);
        wp_localize_script('press-this-app', 'pressThisL10n', $this->i18n());
        wp_register_style('press-this-css', plugin_dir_url(__FILE__) . 'css/press-this.css');
        // TEMP: for tags handling –– @TODO: evaluate
        wp_register_script('tag-box', plugin_dir_url(__FILE__) . 'js/tag-box.js', array('suggest'), false, true);
        // Add press-this-editor.css and remove theme's editor-style.css, if any.
        remove_editor_styles();
        add_filter('mce_css', array($this, 'editor_styles_override'));
        $hook_suffix = 'press-this.php';
        /**
         * @TODO: this is a temp fix to an arcane issue while we're a plugin.
         * See https://github.com/MichaelArestad/Press-This/issues/51
         * Will become irrelevant when/if we merge into core.
         */
        if (function_exists('set_current_screen')) {
            set_current_screen($hook_suffix);
        }
        if (!empty($GLOBALS['is_IE'])) {
            @header('X-UA-Compatible: IE=edge');
        }
        @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
        ?>
<!DOCTYPE html>
<!--[if IE 7]>         <html class="lt-ie9 lt-ie8" <?php 
        language_attributes();
        ?>
> <![endif]-->
<!--[if IE 8]>         <html class="lt-ie9" <?php 
        language_attributes();
        ?>
> <![endif]-->
<!--[if gt IE 8]><!--> <html <?php 
        language_attributes();
        ?>
> <!--<![endif]-->
<head>
	<meta http-equiv="Content-Type" content="<?php 
        bloginfo('html_type');
        ?>
; charset=<?php 
        echo get_option('blog_charset');
        ?>
" />
	<meta name="viewport" content="width=device-width">
	<title><?php 
        echo esc_html(__('Press This!'));
        ?>
</title>

	<script>
		window.wpPressThisData   = <?php 
        echo json_encode($data);
        ?>
;
		window.wpPressThisConfig = <?php 
        echo json_encode($site_settings);
        ?>
;
	</script>

	<script type="text/javascript">
		var ajaxurl = '<?php 
        echo admin_url('admin-ajax.php', 'relative');
        ?>
',
			pagenow = 'press-this',
			typenow = 'post',
			adminpage = 'press-this-php',
			thousandsSeparator = '<?php 
        echo addslashes($wp_locale->number_format['thousands_sep']);
        ?>
',
			decimalPoint = '<?php 
        echo addslashes($wp_locale->number_format['decimal_point']);
        ?>
',
			isRtl = <?php 
        echo (int) is_rtl();
        ?>
;
	</script>

	<?php 
        // $post->ID is needed for the embed shortcode so we can show oEmbed previews in the editor. Maybe find a way without it.
        $post = get_default_post_to_edit('post', true);
        $post_ID = (int) $post->ID;
        wp_enqueue_style('press-this-css');
        wp_enqueue_script('press-this-app');
        wp_enqueue_script('json2');
        wp_enqueue_media(array('post' => $post->ID));
        wp_enqueue_script('editor');
        // TEMP: for tags handling –– @TODO: evaluate
        wp_enqueue_script('tag-box');
        $supports_formats = false;
        $post_format = 0;
        if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) {
            $supports_formats = true;
            if (!($post_format = get_post_format($post->ID))) {
                $post_format = 0;
            }
        }
        /** This action is documented in wp-admin/admin-header.php */
        do_action('admin_enqueue_scripts', $hook_suffix);
        /** This action is documented in wp-admin/admin-header.php */
        do_action('admin_print_styles');
        /** This action is documented in wp-admin/admin-header.php */
        do_action('admin_print_scripts');
        ?>
</head>
<body>
	<div id="adminbar" class="adminbar">
		<h1 id="current-site" class="current-site">
			<span class="dashicons dashicons-wordpress"></span>
			<span><?php 
        bloginfo('name');
        ?>
</span>
		</h1>
		<button type="button" class="options-open button-subtle"><span class="dashicons dashicons-tag"></span><span class="screen-reader-text"><?php 
        _e('Show post options');
        ?>
</span></button>
		<button type="button" class="options-close button-subtle is-hidden"><?php 
        _e('Done');
        ?>
</button>
	</div>

	<div id="scanbar" class="scan">
		<form method="GET">
			<input type="url" name="u" id="url-scan" class="scan-url" value="" placeholder="<?php 
        echo esc_attr(__('Enter a URL to scan'));
        ?>
" />
			<input type="submit" name="url-scan-submit" id="url-scan-submit" class="scan-submit" value="<?php 
        echo esc_attr(__('Scan'));
        ?>
" />
		</form>
	</div>

	<form id="pressthis-form" name="pressthis-form" method="POST" autocomplete="off">
		<input type="hidden" name="post_ID" id="post_ID" value="<?php 
        echo $post_ID;
        ?>
" />
		<?php 
        wp_nonce_field('press-this', 'pressthis-nonce', false);
        ?>
		<?php 
        wp_nonce_field('add-category', '_ajax_nonce-add-category', false);
        ?>
		<input type="hidden" name="title" id="title-field" value="" />

	<div class="wrapper">
		<div class="editor-wrapper">
			<div class="alerts">
				<p class="alert is-notice is-hidden should-upgrade-bookmarklet">
					<?php 
        printf(__('You should upgrade <a href="%s" target="_blank">your bookmarklet</a> to the latest version!'), admin_url('tools.php?page=press_this_options'));
        ?>
				</p>
			</div>

			<div id='app-container' class="editor">
				<span id="title-container-label" class="post-title-placeholder" aria-hidden="true"><?php 
        _e('Post title');
        ?>
</span>
				<h2 id="title-container" class="post-title" contenteditable="true" spellcheck="true" aria-label="<?php 
        _e('Post title');
        ?>
" tabindex="0"></h2>
				<div id='featured-media-container' class="featured-container no-media">
					<div id='all-media-widget' class="all-media">
						<div id='all-media-container'></div>
					</div>
				</div>

				<?php 
        wp_editor('', 'pressthis', array('drag_drop_upload' => true, 'editor_height' => 600, 'media_buttons' => false, 'teeny' => true, 'tinymce' => array('resize' => false, 'wordpress_adv_hidden' => false, 'add_unload_trigger' => false, 'statusbar' => false, 'autoresize_min_height' => 600, 'wp_autoresize_on' => true, 'plugins' => 'lists,media,paste,tabfocus,fullscreen,wordpress,wpautoresize,wpeditimage,wpgallery,wplink,wpview', 'toolbar1' => 'bold,italic,bullist,numlist,blockquote,link,unlink', 'toolbar2' => 'undo,redo'), 'quicktags' => false));
        ?>
			</div>
		</div>

		<div class="options-panel is-off-screen is-hidden">
			<div class="post-options">
				<?php 
        if ($supports_formats) {
            ?>
					<button type="button" class="button-reset post-option">
						<span class="dashicons dashicons-admin-post"></span>
						<span class="post-option-title"><?php 
            _e('Format');
            ?>
</span>
						<span class="post-option-contents" id="post-option-post-format"><?php 
            echo esc_html(get_post_format_string($post_format));
            ?>
</span>
						<span class="dashicons dashicons-arrow-right-alt2"></span>
					</button>
				<?php 
        }
        ?>
				<button type="button" class="button-reset post-option">
					<span class="dashicons dashicons-category"></span>
					<span class="post-option-title"><?php 
        _e('Categories');
        ?>
</span>
					<span class="post-option-contents" id="post-option-category"></span>
					<span class="dashicons dashicons-arrow-right-alt2"></span>
				</button>
				<button type="button" class="button-reset post-option">
					<span class="dashicons dashicons-tag"></span>
					<span class="post-option-title"><?php 
        _e('Tags');
        ?>
</span>
					<span class="post-option-contents" id="post-option-tags"></span>
					<span class="dashicons dashicons-arrow-right-alt2"></span>
				</button>
			</div>

			<?php 
        if ($supports_formats) {
            ?>
				<div class="setting-modal is-off-screen is-hidden">
					<button type="button" class="button-reset modal-close"><span class="dashicons dashicons-arrow-left-alt2"></span><span class="setting-title"><?php 
            _e('Post format');
            ?>
</span></button>
					<?php 
            $this->post_formats_html($post);
            ?>
				</div>
			<?php 
        }
        ?>

			<div class="setting-modal is-off-screen is-hidden">
				<button type="button" class="button-reset modal-close"><span class="dashicons dashicons-arrow-left-alt2"></span><span class="setting-title"><?php 
        _e('Categories');
        ?>
</span></button>
				<?php 
        $this->categories_html($post);
        ?>
			</div>

			<div class="setting-modal tags is-off-screen is-hidden">
				<button type="button" class="button-reset modal-close"><span class="dashicons dashicons-arrow-left-alt2"></span><span class="setting-title"><?php 
        _e('Tags');
        ?>
</span></button>
				<?php 
        $this->tags_html($post);
        ?>
			</div>
		</div><!-- .options-panel -->
	</div><!-- .wrapper -->

	<div class="press-this-actions">
		<div class="pressthis-media-buttons">
			<button type="button" class="insert-media button-subtle" data-editor="pressthis">
				<span class="dashicons dashicons-admin-media"></span>
				<span class="screen-reader-text"><?php 
        _e('Add Media');
        ?>
</span>
			</button>
		</div>
		<div class="post-actions">
			<button type="button" class="button-subtle" id="draft-field"><?php 
        _e('Save Draft');
        ?>
</button>
			<button type="button" class="button-primary" id="publish-field"><?php 
        _e('Publish');
        ?>
</button>
		</div>
	</div>
	</form>

	<?php 
        // TODO: consider running "special" press-this hooks here?
        // Maybe better so we don't output stuff accidentaly added by plugins. Would probably prevent some errors.
        do_action('admin_footer', '');
        do_action('admin_print_footer_scripts');
        ?>
</body>
</html>
<?php 
        die;
    }
    function contact_support()
    {
        if (current_user_can('subscriber')) {
            return false;
        }
        ?>
		<style>
			.mainwp_info-box-yellow {
				margin: 5px 0 15px;
				padding: .6em;
				background: #ffffe0;
				border: 1px solid #e6db55;
				border-radius: 3px;
				-moz-border-radius: 3px;
				-webkit-border-radius: 3px;
				clear: both;
			}
		</style>
		<?php 
        if (isset($_POST['submit'])) {
            if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], '_contactNonce')) {
                return false;
            }
            $from_page = $_POST['mainwp_branding_send_from_page'];
            $back_link = get_option('mainwp_branding_message_return_sender');
            $back_link = !empty($back_link) ? $back_link : 'Go Back';
            $back_link = !empty($from_page) ? '<a href="' . esc_url($from_page) . '" title="' . esc_attr($back_link) . '">' . esc_html($back_link) . '</a>' : '';
            if ($this->send_support_mail()) {
                $send_email_message = get_option('mainwp_branding_send_email_message');
                if (!empty($send_email_message)) {
                    $send_email_message = stripslashes($send_email_message);
                } else {
                    $send_email_message = 'Your Message was successfully submitted.';
                }
            } else {
                $send_email_message = __('Error: send mail failed.');
            }
            ?>
			<div
				class="mainwp_info-box-yellow"><?php 
            echo esc_html($send_email_message . '&nbsp;&nbsp' . $back_link);
            ?>
</div><?php 
        } else {
            $from_page = '';
            if (isset($_GET['from_page'])) {
                $from_page = urldecode($_GET['from_page']);
            } else {
                $protocol = isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https://' : 'http://';
                $fullurl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                $from_page = urldecode($fullurl);
            }
            $support_message = get_option('mainwp_branding_support_message');
            $support_message = nl2br(stripslashes($support_message));
            ?>
			<form action="" method="post">
				<div style="width: 99%;">
					<h2><?php 
            echo esc_html($this->settings['contact_support_label']);
            ?>
</h2>

					<div style="height: auto; margin-bottom: 10px; text-align: left">
						<p><?php 
            echo wp_kses_post($support_message);
            ?>
</p>

						<div style="max-width: 650px;">
							<?php 
            remove_editor_styles();
            // stop custom theme styling interfering with the editor
            wp_editor('', 'mainwp_branding_contact_message_content', array('textarea_name' => 'mainwp_branding_contact_message_content', 'textarea_rows' => 10, 'teeny' => true, 'wpautop' => true, 'media_buttons' => false));
            ?>
						</div>
					</div>
					<br/>
					<?php 
            $button_title = get_option('mainwp_branding_submit_button_title');
            $button_title = !empty($button_title) ? $button_title : __('Submit');
            ?>
					<input id="mainwp-branding-contact-support-submit" type="submit" name="submit"
					       value="<?php 
            echo esc_attr($button_title);
            ?>
"
					       class="button-primary button" style="float: left"/>
				</div>
				<input type="hidden" name="mainwp_branding_send_from_page"
				       value="<?php 
            echo esc_url($from_page);
            ?>
"/>
				<input type="hidden" name="_wpnonce" value="<?php 
            echo esc_attr(wp_create_nonce('_contactNonce'));
            ?>
"/>
			</form>
		<?php 
        }
    }
Example #5
0
 function mac_vis_editor()
 {
     global $options;
     if (isset($options['enable_mac_editor']) && $options['enable_mac_editor'] != "") {
         remove_editor_styles();
         add_editor_style('editor-fontsafe-style.css');
     }
 }
Example #6
0
 /**
  * Add a description editor to the single snippet page
  * @param Snippet $snippet The snippet being used for this page
  */
 function render_description_editor(Snippet $snippet)
 {
     $settings = code_snippets_get_settings();
     $settings = $settings['description_editor'];
     $heading = __('Description', 'code-snippets');
     /* Hack to remove space between heading and editor tabs */
     if (!$settings['media_buttons'] && 'false' !== get_user_option('rich_editing')) {
         $heading = "<div>{$heading}</div>";
     }
     echo '<label for="snippet_description"><h3>', $heading, '</h3></label>';
     remove_editor_styles();
     // stop custom theme styling interfering with the editor
     wp_editor($snippet->desc, 'description', apply_filters('code_snippets/admin/description_editor_settings', array('textarea_name' => 'snippet_description', 'textarea_rows' => $settings['rows'], 'teeny' => !$settings['use_full_mce'], 'media_buttons' => $settings['media_buttons'])));
 }
Example #7
0
        function admin_head()
        {
            global $pagenow, $post;
            if (!empty($post) && $post->post_type == SPOTS_POST_TYPE && $pagenow == 'post.php') {
                remove_editor_styles();
                add_editor_style(apply_filters('spots_editor_css', null));
            }
            ?>

			<style type="text/css">
				#postdivrich .mce-i-addspotbutton,
				#wpbody-content span.mce_addspotbutton,
				#adminmenu #menu-posts-spot div.wp-menu-image,
				#icon-edit.icon32-posts-spot {
					background-image: url( <?php 
            echo esc_url(SPOTS_URL);
            ?>
/assets/icon.png );
					background-repeat:no-repeat;
					background-color:transparent;
					background-position:0 0;
					background-size: initial;
				}

				@media
		        only screen and (-webkit-min-device-pixel-ratio: 1.5),
		        only screen and (   min--moz-device-pixel-ratio: 1.5),
		        only screen and (     -o-min-device-pixel-ratio: 3/2),
		        only screen and (        min-device-pixel-ratio: 1.5),
		        only screen and (                min-resolution: 1.5dppx) {
					#postdivrich .mce-i-addspotbutton,
					#wpbody-content span.mce_addspotbutton,
					#adminmenu #menu-posts-spot div.wp-menu-image,
					#icon-edit.icon32-posts-spot {
						-webkit-background-size: 85px 56px;
	                	-moz-background-size: 85px 56px;
	                	background-size: 85px 56px;
					}
				}

				#postdivrich .mce-i-addspotbutton:hover,
				#wpbody-content span.mce_addspotbutton:hover	{ background-position: 0 -20px }
				#adminmenu #menu-posts-spot div.wp-menu-image 		{ background-position: -20px 0 }
				#adminmenu #menu-posts-spot:hover div.wp-menu-image{ background-position: -20px -28px }
				#icon-edit.icon32-posts-spot 						{ background-position: -48px 0 }
				.acInput {width: 200px;}
				.acResults {padding: 0px;border: 1px solid WindowFrame;background-color: Window;overflow: hidden;}
				.acResults ul {width: 100%;list-style-position: outside;list-style: none;padding: 0;margin: 0;}
				.acResults li {margin: 0px;padding: 2px 5px;cursor: pointer;display: block;width: 100%;font: menu;font-size: 12px;overflow: hidden;}
				.acLoading {background : url( 'indicator.gif' ) right center no-repeat;}
				.acSelect {background-color: Highlight;color: HighlightText;}
			</style>
			<?php 
        }
    /**
     * Add a description editor to the single snippet page
     *
     * @since  1.7
     * @access private
     * @param  object $snippet The snippet being used for this page
     * @return void
     */
    function description_editor_box($snippet)
    {
        ?>

		<label for="snippet_description">
			<h3><div><?php 
        _e('Description', 'code-snippets');
        ?>
</div></h3>
		</label>

		<?php 
        remove_editor_styles();
        // stop custom theme styling interfering with the editor
        wp_editor($snippet->description, 'description', apply_filters('code_snippets/admin/description_editor_settings', array('textarea_name' => 'snippet_description', 'textarea_rows' => 10, 'teeny' => true, 'media_buttons' => false)));
    }
Example #9
0
/**
 * Add a description editor to the single snippet page
 *
 * @since 1.7
 * @access private
 * @param object $snippet The snippet being used for this page
 */
function code_snippets_description_editor_box($snippet)
{
    $settings = code_snippets_get_settings();
    $settings = $settings['description_editor'];
    $media_buttons = $settings['media_buttons'];
    echo '<label for="snippet_description"><h3>';
    $heading = __('Description', 'code-snippets');
    echo $media_buttons ? $heading : "<div>{$heading}</div>";
    echo '</h3></label>';
    remove_editor_styles();
    // stop custom theme styling interfering with the editor
    wp_editor($snippet->description, 'description', apply_filters('code_snippets/admin/description_editor_settings', array('textarea_name' => 'snippet_description', 'textarea_rows' => $settings['rows'], 'teeny' => !$settings['use_full_mce'], 'media_buttons' => $media_buttons)));
}
Example #10
0
    return $files;
}

/**
 * Avoid Theme Support feature
 * We are using Option
 */
add_theme_support('custom-header');
remove_theme_support('custom-header');

add_theme_support('custom-background');
remove_theme_support('custom-background');


add_editor_style();
remove_editor_styles();

if (!isset($content_width)) {
    $content_width = 474;
}

add_action("init", "charity_rewrite_rules");

function charity_rewrite_rules() {
    flush_rewrite_rules();
}

/*
 *  Woocommerce Theme Support
 */
add_action('after_setup_theme', 'charity_woocommerce_support');
 function admin_init()
 {
     $this->add_caps();
     $this->maybe_upgrade();
     if (!empty($_GET['_wp_http_referer']) && (isset($_GET['page']) && in_array(SPNL()->validate->page($_GET['page']), $this->adminpages))) {
         //safe redirect with esc_url 4/20
         wp_safe_redirect(esc_url_raw(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))));
         exit;
     }
     if (isset($_REQUEST['post_id'])) {
         $p = get_post($_REQUEST['post_id']);
         if ($p !== null && $p->post_type == 'sp_newsletters') {
             add_filter('disable_captions', create_function('$a', 'return true;'));
         }
     }
     //Removed in 0.9.2
     //$this->create_initial_list();
     /*
     if( SendPress_Option::get('emails-today') == false ){
     	$emails_today = array( date("z") => '0' );
     	SendPress_Option::set('emails-today', $emails_today);
     }
     
     $emails_today = SendPress_Option::get('emails-today');
     $emails_today[date("z") + 1 ] = '0';
     
     SendPress_Option::set('emails-today', $emails_today);
     */
     //SendPress_Option::set('emails-today', '');
     //SendPress_Option::set('allow_tracking', '');
     //wp_clear_scheduled_hook( 'sendpress_cron_action' );
     // Schedule an action if it's not already scheduled
     /*
     if ( ! wp_next_scheduled( 'sendpress_cron_action' ) ) {
         wp_schedule_event( time(), 'tenminutes',  'sendpress_cron_action' );
     }
     */
     //wp_clear_scheduled_hook( 'sendpress_cron_action' );
     /*
     		add_meta_box( 'email-status', __( 'Email Status', 'sendpress' ), array( $this, 'email_meta_box' ), $this->_email_post_type, 'side', 'low' );
     */
     //MAKE SURE WE ARE ON AN ADMIN PAGE
     if (isset($_GET['page']) && in_array($_GET['page'], $this->adminpages)) {
         remove_action('admin_init', 'Zotpress_add_meta_box', 1);
         remove_filter('mce_external_plugins', 'cforms_plugin');
         remove_filter('mce_buttons', 'cforms_button');
         remove_filter("mce_plugins", "cforms_plugin");
         remove_filter('mce_buttons', 'cforms_button');
         remove_filter('tinymce_before_init', 'cforms_button_script');
         global $wp_filter;
         $wp_filter['admin_notices'] = array();
         if (SPNL()->validate->page($_GET['page']) == 'sp-templates' || isset($_GET['view']) && $_GET['view'] == 'style-email') {
             wp_register_script('sendpress_js_styler', SENDPRESS_URL . 'js/styler.js', '', SENDPRESS_VERSION);
         }
         if (defined('WPE_PLUGIN_BASE')) {
             add_action('admin_print_styles', array($this, 'remove_wpengine_style'));
         }
         $this->_page = SPNL()->validate->page($_GET['page']);
         add_filter('tiny_mce_before_init', array($this, 'myformatTinyMCE'));
         if (isset($_GET['beta'])) {
             SendPress_Option::set('beta', absint($_GET['beta']));
         }
         remove_editor_styles();
         add_filter('mce_css', array($this, 'plugin_mce_css'));
         //Stop Facebook Plugin from posting emails to Facebook.
         remove_action('transition_post_status', 'fb_publish_later', 10, 3);
         $tiny = new SendPress_TinyMCE();
         $this->_current_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : '';
         $view_class = $this->get_view_class($this->_page, $this->_current_view);
         $view_class = new $view_class();
         $view_class->admin_init();
         add_action('sendpress_admin_scripts', array($view_class, 'admin_scripts_load'));
         $view_class = $this->get_view_class($this->_page, $this->_current_view);
         $this->_current_action = isset($_GET['action']) ? sanitize_text_field($_GET['action']) : '';
         $this->_current_action = isset($_GET['action2']) ? sanitize_text_field($_GET['action2']) : $this->_current_action;
         $this->_current_action = isset($_POST['action2']) ? sanitize_text_field($_POST['action2']) : $this->_current_action;
         $this->_current_action = isset($_POST['action']) && sanitize_text_field($_POST['action']) !== '-1' ? sanitize_text_field($_POST['action']) : $this->_current_action;
         $method = str_replace("-", "_", $this->_current_action);
         $method = str_replace(" ", "_", $method);
         if (!empty($_POST) && (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], $this->_nonce_value))) {
             if (method_exists($view_class, $method)) {
                 $save_class = new $view_class();
                 $save_class->{$method}();
                 //print_r($save_class);
             } elseif (method_exists($view_class, 'save')) {
                 //$view_class::save($this);
                 $save_class = new $view_class();
                 $save_class->save($_POST, $this);
             } else {
                 require_once SENDPRESS_PATH . 'inc/helpers/sendpress-post-actions.php';
             }
         } else {
             if (isset($_GET['action']) || isset($_GET['action2'])) {
                 $this->_current_action = sanitize_text_field($_GET['action']);
                 $this->_current_action = isset($_GET['action2']) && sanitize_text_field($_GET['action2']) !== '-1' ? sanitize_text_field($_GET['action2']) : $this->_current_action;
                 $method = str_replace("-", "_", $this->_current_action);
                 $method = str_replace(" ", "_", $method);
                 if (method_exists($view_class, $method)) {
                     $save_class = new $view_class();
                     call_user_func(array($view_class, $method), $_GET, $this);
                 }
                 require_once SENDPRESS_PATH . 'inc/helpers/sendpress-get-actions.php';
             }
         }
     }
 }
Example #12
0
 public function enqueue_scripts()
 {
     if (!$this->is_editor_screen()) {
         return;
     }
     // Glyphicons
     if (!wp_style_is('glyphicons')) {
         wp_enqueue_style('glyphicons', plugins_url('css/glyphicons/css/glyphicons.css', MMTL_FILE), null, '1.9.2');
     }
     // Font Awesome
     if (!wp_style_is('font-awesome')) {
         wp_enqueue_style('font-awesome', plugins_url('css/font-awesome/css/font-awesome.min.css', MMTL_FILE), null, '4.5.0');
     }
     // Featherlight
     if (!wp_script_is('featherlight')) {
         wp_enqueue_script('featherlight', plugins_url('js/featherlight/featherlight.min.js', MMTL_FILE), array('jquery'), '1.3.4', true);
     }
     // jQuery UI
     if (!wp_style_is('jquery-ui-structure')) {
         wp_enqueue_style('jquery-ui-structure', plugins_url('css/jquery-ui.structure.min.css', MMTL_FILE), null, '1.11.4');
     }
     wp_enqueue_script('jquery');
     wp_enqueue_script('jquery-ui-sortable');
     wp_enqueue_script('jquery-ui-tabs');
     // Table Layout
     wp_enqueue_style('table-layout');
     wp_enqueue_style('table-layout-editor', plugins_url('css/editor.min.css', MMTL_FILE));
     wp_enqueue_style('table-layout-editor-style', plugins_url('css/editor-style.min.css', MMTL_FILE));
     wp_enqueue_script('table-layout-editor', plugins_url('js/editor/main.js', MMTL_FILE), null, false, true);
     wp_enqueue_script('table-layout-editor-common', plugins_url('js/editor/common.js', MMTL_FILE), null, false, true);
     wp_enqueue_script('table-layout-admin', plugins_url('js/admin.js', MMTL_FILE), null, false, true);
     $options = apply_filters('mmtl_options', array('post_id' => $this->get_post_id(), 'post_editor_id' => MMTL_POST_EDITOR_ID, 'ajaxurl' => admin_url('admin-ajax.php'), 'noncename' => MMTL_NONCE_NAME, 'nonce' => wp_create_nonce('MMTL_Editor'), 'confirm_delete' => __('Are you sure you want to delete this component?', 'table-layout'), 'control_label_add' => __('Add', 'table-layout'), 'control_label_edit' => __('Edit', 'table-layout'), 'control_label_copy' => __('Copy', 'table-layout'), 'control_label_delete' => __('Delete', 'table-layout'), 'control_label_toggle' => __('Toggle', 'table-layout'), 'meta_title_id' => __('ID', 'table-layout'), 'meta_title_class' => __('Class', 'table-layout'), 'meta_title_bg_image' => __('Background image', 'table-layout'), 'meta_title_push' => __('Push', 'table-layout'), 'meta_title_pull' => __('Pull', 'table-layout')));
     wp_localize_script('table-layout-admin', 'MMTL_Options', $options);
     remove_editor_styles();
 }