/**
  * Prevent Divi from adding their stuff to GV pages
  */
 public function add_hooks_admin_init()
 {
     if (GravityView_Admin::is_admin_page()) {
         // Prevent Divi from adding import/export modal dialog
         remove_action('admin_init', 'et_pb_register_builder_portabilities');
         // Divi theme adds their quicktag shortcode buttons on a View CPT. This causes JS errors.
         remove_action('admin_head', 'et_add_simple_buttons');
     }
 }
Example #2
0
 /**
  * Get text for no views found.
  * @todo Move somewhere appropriate.
  * @return string HTML message with no container tags.
  */
 static function no_views_text()
 {
     if (!class_exists('GravityView_Admin')) {
         require_once GRAVITYVIEW_DIR . 'includes/class-admin.php';
     }
     // Floaty the astronaut
     $image = GravityView_Admin::get_floaty();
     $not_found = sprintf(esc_attr__("%sYou don't have any active views. Let&rsquo;s go %screate one%s!%s\n\nIf you feel like you're lost in space and need help getting started, check out the %sGetting Started%s page.", 'gravityview'), '<h3>', '<a href="' . admin_url('post-new.php?post_type=gravityview') . '">', '</a>', '</h3>', '<a href="' . admin_url('edit.php?post_type=gravityview&page=gv-getting-started') . '">', '</a>');
     return $image . wpautop($not_found);
 }
    /**
     * @inheritDoc
     */
    public function form($instance)
    {
        // @todo Make compatible with Customizer
        if ($this->is_preview()) {
            $warning = sprintf(esc_html__('This widget is not configurable from this screen. Please configure it on the %sWidgets page%s.', 'gravityview'), '<a href="' . admin_url('widgets.php') . '">', '</a>');
            echo wpautop(GravityView_Admin::get_floaty() . $warning);
            return;
        }
        $defaults = array('title' => '', 'view_id' => 0, 'post_id' => '', 'search_fields' => '');
        $instance = wp_parse_args((array) $instance, $defaults);
        $title = $instance['title'];
        $view_id = $instance['view_id'];
        $post_id = $instance['post_id'];
        $search_fields = $instance['search_fields'];
        $views = GVCommon::get_all_views();
        // If there are no views set up yet, we get outta here.
        if (empty($views)) {
            ?>
			<div id="select_gravityview_view">
				<div class="wrap"><?php 
            echo GravityView_Post_Types::no_views_text();
            ?>
</div>
			</div>
			<?php 
            return;
        }
        ?>

		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'gravityview');
        ?>
 <input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" /></label></p>

		<?php 
        /**
         * Display errors generated for invalid embed IDs
         * @see GravityView_View_Data::is_valid_embed_id
         */
        if (isset($instance['updated']) && empty($instance['view_id'])) {
            ?>
			<div class="error inline hide-on-view-change">
				<p><?php 
            esc_html_e('Please select a View to search.', 'gravityview');
            ?>
</p>
			</div>
			<?php 
            unset($error);
        }
        ?>

		<p>
			<label for="gravityview_view_id"><?php 
        _e('View:', 'gravityview');
        ?>
</label>
			<select id="gravityview_view_id" name="<?php 
        echo $this->get_field_name('view_id');
        ?>
" class="widefat">
				<option value=""><?php 
        esc_html_e('&mdash; Select a View &mdash;', 'gravityview');
        ?>
</option>
				<?php 
        foreach ($views as $view_option) {
            $title = empty($view_option->post_title) ? __('(no title)', 'gravityview') : $view_option->post_title;
            echo '<option value="' . $view_option->ID . '" ' . selected(esc_attr($view_id), $view_option->ID, false) . '>' . esc_html(sprintf('%s #%d', $title, $view_option->ID)) . '</option>';
        }
        ?>
			</select>

		</p>

		<?php 
        /**
         * Display errors generated for invalid embed IDs
         * @see GravityView_View_Data::is_valid_embed_id
         */
        if (!empty($instance['error_post_id'])) {
            ?>
			<div class="error inline">
				<p><?php 
            echo $instance['error_post_id'];
            ?>
</p>
			</div>
			<?php 
            unset($error);
        }
        ?>

		<p>
			<label for="<?php 
        echo $this->get_field_id('post_id');
        ?>
"><?php 
        esc_html_e('If Embedded, Page ID:', 'gravityview');
        ?>
</label>
			<input class="code" size="3" id="<?php 
        echo $this->get_field_id('post_id');
        ?>
" name="<?php 
        echo $this->get_field_name('post_id');
        ?>
" type="text" value="<?php 
        echo esc_attr($post_id);
        ?>
" />
			<span class="howto"><?php 
        esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview');
        echo ' ' . gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more&hellip;', 'gravityview'), 'target=_blank');
        ?>
</span>
		</p>

		<hr />

		<?php 
        // @todo: move style to CSS
        ?>
		<div style="margin-bottom: 1em;">
			<label class="screen-reader-text" for="<?php 
        echo $this->get_field_id('search_fields');
        ?>
"><?php 
        _e('Searchable fields:', 'gravityview');
        ?>
</label>
			<div class="gv-widget-search-fields" title="<?php 
        esc_html_e('Search Fields', 'gravityview');
        ?>
">
				<input id="<?php 
        echo $this->get_field_id('search_fields');
        ?>
" name="<?php 
        echo $this->get_field_name('search_fields');
        ?>
" type="hidden" value="<?php 
        echo esc_attr($search_fields);
        ?>
" class="gv-search-fields-value">
			</div>

		</div>

		<script>
			// When the widget is saved or added, refresh the Merge Tags (here for backward compatibility)
			// WordPress 3.9 added widget-added and widget-updated actions
			jQuery('#<?php 
        echo $this->get_field_id('view_id');
        ?>
').trigger( 'change' );
		</script>
	<?php 
    }
Example #4
0
    /**
     * Display a nice placeholder in the admin for the entry
     *
     * @param array $matches The regex matches from the provided regex when calling wp_embed_register_handler()
     * @param array $attr Embed attributes.
     * @param string $url The original URL that was matched by the regex.
     * @param array $rawattr The original unmodified attributes.
     * @return string The embed HTML.
     */
    private function render_admin($matches, $attr, $url, $rawattr)
    {
        global $wp_version;
        // Floaty the astronaut
        $image = GravityView_Admin::get_floaty();
        $embed_heading = sprintf(esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id);
        $embed_text = sprintf(esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id);
        return '
		<div class="loading-placeholder" style="background-color:#e6f0f5;">
			<h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">' . $image . $embed_heading . '</h3>
			<p style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">
				' . $embed_text . '
			</p>
			<br style="clear: both;">
		</div>';
    }
Example #5
0
 private function __construct()
 {
     require_once GRAVITYVIEW_DIR . 'includes/class-admin.php';
     // If Gravity Forms doesn't exist or is outdated, load the admin view class to
     // show the notice, but not load any post types or process shortcodes.
     // Without Gravity Forms, there is no GravityView. Beautiful, really.
     if (!GravityView_Admin::check_gravityforms()) {
         // If the plugin's not loaded, might as well hide the shortcode for people.
         add_shortcode('gravityview', array($this, '_shortcode_gf_notice'), 10, 3);
         return;
     }
     // Load Extensions
     // @todo: Convert to a scan of the directory or a method where this all lives
     include_once GRAVITYVIEW_DIR . 'includes/extensions/edit-entry/class-edit-entry.php';
     include_once GRAVITYVIEW_DIR . 'includes/extensions/delete-entry/class-delete-entry.php';
     // Load WordPress Widgets
     include_once GRAVITYVIEW_DIR . 'includes/wordpress-widgets/register-wordpress-widgets.php';
     // Load GravityView Widgets
     include_once GRAVITYVIEW_DIR . 'includes/widgets/register-gravityview-widgets.php';
     // Add oEmbed
     include_once GRAVITYVIEW_DIR . 'includes/class-oembed.php';
     // Add logging
     include_once GRAVITYVIEW_DIR . 'includes/class-logging.php';
     include_once GRAVITYVIEW_DIR . 'includes/class-ajax.php';
     include_once GRAVITYVIEW_DIR . 'includes/class-settings.php';
     include_once GRAVITYVIEW_DIR . 'includes/class-frontend-views.php';
     include_once GRAVITYVIEW_DIR . 'includes/helper-functions.php';
     include_once GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-list.php';
     include_once GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php';
     /** @since 1.8.4 */
     include_once GRAVITYVIEW_DIR . 'includes/class-data.php';
     include_once GRAVITYVIEW_DIR . 'includes/class-gvlogic-shortcode.php';
     // Load plugin text domain
     add_action('init', array($this, 'load_plugin_textdomain'), 1);
     // Load frontend files
     add_action('init', array($this, 'frontend_actions'), 20);
     // Load default templates
     add_action('init', array($this, 'register_default_templates'), 11);
 }
Example #6
0
 /**
  * Display a notice if the plugin is inactive.
  * @return void
  */
 function license_key_notice()
 {
     // Show license notice on all GV pages, except for settings page
     if (gravityview_is_admin_page('', 'settings')) {
         return;
     }
     $license_status = self::getSetting('license_key_status');
     $license_id = self::getSetting('license_key');
     $license_id = empty($license_id) ? 'license' : $license_id;
     $message = esc_html__('Your GravityView license %s. This means you&rsquo;re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview');
     $title = __('Inactive License', 'gravityview');
     $status = '';
     switch ($license_status) {
         case 'invalid':
             $title = __('Invalid License', 'gravityview');
             $status = __('is invalid', 'gravityview');
             break;
         case 'deactivated':
             $status = __('is inactive', 'gravityview');
             break;
         case 'site_inactive':
             $status = __('has not been activated', 'gravityview');
             break;
     }
     $message = sprintf($message, $status, '<a href="' . admin_url('edit.php?post_type=gravityview&amp;page=gravityview_settings') . '">', '</a>', '<a href="https://gravityview.co/pricing/">', '</a>');
     if (!empty($status)) {
         GravityView_Admin::add_notice(array('message' => $message, 'class' => 'updated', 'title' => $title, 'dismiss' => sha1($license_status . '_' . $license_id)));
     }
 }
Example #7
0
function gravityview_is_admin_page($hook = '', $page = NULL)
{
    return GravityView_Admin::is_admin_page($hook, $page);
}
 /**
  * Check whether the extension is supported:
  *
  * - Checks if GravityView and Gravity Forms exist
  * - Checks GravityView and Gravity Forms version numbers
  * - Sets
  *
  * @uses GravityView_Admin::check_gravityforms()
  * @return boolean Is the extension supported?
  */
 protected function is_extension_supported()
 {
     self::$is_compatible = true;
     if (!class_exists('GravityView_Plugin')) {
         $message = sprintf(__('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), $this->_title);
         self::add_notice($message);
         do_action('gravityview_log_error', __CLASS__ . '[is_compatible] ' . $message);
         self::$is_compatible = false;
     } else {
         if (false === version_compare(GravityView_Plugin::version, $this->_min_gravityview_version, ">=")) {
             $message = sprintf(__('The %s Extension requires GravityView Version %s or newer.', 'gravityview'), $this->_title, '<tt>' . $this->_min_gravityview_version . '</tt>');
             self::add_notice($message);
             do_action('gravityview_log_error', __CLASS__ . '[is_compatible] ' . $message);
             self::$is_compatible = false;
         } else {
             if (!GravityView_Admin::check_gravityforms()) {
                 self::$is_compatible = false;
             }
         }
     }
     return self::$is_compatible;
 }
Example #9
0
 /**
  * Outputs the admin notices generated by the plugin
  *
  * @return void
  */
 public function admin_notice()
 {
     if (empty(self::$admin_notices)) {
         return;
     }
     if (GravityView_Plugin::is_network_activated() && !is_main_site()) {
         return;
     }
     //don't display a message if use has dismissed the message for this version
     self::$dismissed_notices = (array) get_transient('gravityview_dismissed_notices');
     foreach (self::$admin_notices as $notice) {
         if (false === $this->_maybe_show_notice($notice)) {
             continue;
         }
         echo '<div id="message" class="' . esc_attr($notice['class']) . '">';
         // Too cute to leave out.
         echo GravityView_Admin::get_floaty();
         if (!empty($notice['title'])) {
             echo '<h3>' . esc_html($notice['title']) . '</h3>';
         }
         echo wpautop($notice['message']);
         if (!empty($notice['dismiss'])) {
             $dismiss = esc_attr($notice['dismiss']);
             $url = esc_url(add_query_arg(array('gv-dismiss' => wp_create_nonce('dismiss'), 'notice' => $dismiss)));
             echo wpautop('<a href="' . $url . '" data-notice="' . $dismiss . '" class="button-small button button-secondary">' . esc_html__('Dismiss', 'gravityview') . '</a>');
         }
         echo '<div class="clear"></div>';
         echo '</div>';
     }
     //reset the notices handler
     self::$admin_notices = array();
 }