public function widget($args, $instance) { // Don't show unless a View ID has been set. if (empty($instance['view_id'])) { do_action('gravityview_log_debug', sprintf('%s[widget]: No View ID has been defined. Not showing the widget.', get_class($this)), $instance); return; } /** This filter is documented in wp-includes/default-widgets.php */ $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); echo $args['before_widget']; if ($title) { echo $args['before_title'] . $title . $args['after_title']; } // @todo Add to the widget configuration form $instance['search_layout'] = apply_filters('gravityview/widget/search/layout', 'vertical', $instance); $instance['context'] = 'wp_widget'; // form $instance['form_id'] = GVCommon::get_meta_form_id($instance['view_id']); $instance['form'] = GVCommon::get_form($instance['form_id']); // We don't want to overwrite existing context, etc. $previous_view = GravityView_View::getInstance(); /** @hack */ new GravityView_View($instance); GravityView_Widget_Search::getInstance()->render_frontend($instance); /** * Restore previous View context * @hack */ new GravityView_View($previous_view); echo $args['after_widget']; }
/** * Returns the form object for a given Form ID. * @see GVCommon::get_form() * @access public * @param mixed $form_id * @return mixed False: no form ID specified or Gravity Forms isn't active. Array: Form returned from Gravity Forms */ function gravityview_get_form($form_id) { return GVCommon::get_form($form_id); }
/** * Calculate the approve field.input id * * @access public * @static * @param mixed $form GF Form or Form ID * @return false|null|string Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set. */ public static function get_approved_column($form) { if (empty($form)) { return null; } if (!is_array($form)) { $form = GVCommon::get_form($form); } foreach ($form['fields'] as $key => $field) { $field = (array) $field; if (!empty($field['gravityview_approved'])) { if (!empty($field['inputs'][0]['id'])) { return $field['inputs'][0]['id']; } } // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. if ('checkbox' == $field['type'] && isset($field['inputs']) && is_array($field['inputs'])) { foreach ($field['inputs'] as $key2 => $input) { if (strtolower($input['label']) == 'approved') { return $input['id']; } } } } return null; }
/** * Add custom merge tags to merge tag options. DO NOT OVERRIDE. * * @internal Not to be overridden by fields * * @since 1.8.4 * * @param array $custom_merge_tags * @param int $form_id GF Form ID * @param GF_Field[] $fields Array of fields in the form * @param string $element_id The ID of the input that Merge Tags are being used on * * @return array Modified merge tags */ public function _filter_gform_custom_merge_tags($custom_merge_tags = array(), $form_id, $fields = array(), $element_id = '') { $form = GVCommon::get_form($form_id); $field_merge_tags = $this->custom_merge_tags($form, $fields); return array_merge($custom_merge_tags, $field_merge_tags); }