Ejemplo n.º 1
0
/**
 * @global GravityView_View $gravityview_view
 * @return string View context "directory", "single", or "edit"
 */
function gravityview_get_context()
{
    $context = '';
    /**
     * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n
     * The Edit Entry functionality overrides this value.
     * @param boolean $is_edit_entry
     */
    $is_edit_entry = apply_filters('gravityview_is_edit_entry', false);
    if ($is_edit_entry) {
        $context = 'edit';
    } else {
        if (class_exists('GravityView_frontend') && ($single = GravityView_frontend::is_single_entry())) {
            $context = 'single';
        } else {
            if (class_exists('GravityView_View')) {
                $context = GravityView_View::getInstance()->getContext();
            }
        }
    }
    return $context;
}
Ejemplo n.º 2
0
/**
 * Theme function to identify if it is a Single Entry View
 *
 * @since  1.5.4
 * @return bool|string False if not, single entry slug if true
 */
function gravityview_is_single_entry()
{
    return GravityView_frontend::is_single_entry();
}
 /**
  * TODO: This seems to be hacky... we should remove it. Entry is set when updating the form using setup_vars()!
  * Get the current entry and set it if it's not yet set.
  * @return array Gravity Forms entry array
  */
 private function get_entry()
 {
     if (empty($this->entry)) {
         // Get the database value of the entry that's being edited
         $this->entry = gravityview_get_entry(GravityView_frontend::is_single_entry());
     }
     return $this->entry;
 }
 /**
  * Add $this->shortcode_name shortcode to output self::render_frontend()
  */
 function add_shortcode($run_on_singular = true)
 {
     global $post;
     if (GravityView_Plugin::is_admin()) {
         return;
     }
     if (empty($this->shortcode_name)) {
         return;
     }
     // If the widget shouldn't output on single entries, don't show it
     if (empty($this->show_on_single) && class_exists('GravityView_frontend') && GravityView_frontend::is_single_entry()) {
         do_action('gravityview_log_debug', sprintf('%s[add_shortcode]: Skipping; set to not run on single entry.', get_class($this)));
         add_shortcode($this->shortcode_name, '__return_null');
         return;
     }
     if (!has_gravityview_shortcode($post)) {
         do_action('gravityview_log_debug', sprintf('%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class($this)));
         add_shortcode($this->shortcode_name, '__return_null');
         return;
     }
     add_shortcode($this->shortcode_name, array($this, 'render_shortcode'));
 }