本文整理汇总了PHP中GVCommon类的典型用法代码示例。如果您正苦于以下问题:PHP GVCommon类的具体用法?PHP GVCommon怎么用?PHP GVCommon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GVCommon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content
/**
* Filter the value of the field
*
* @todo Consider how to add to parent class
*
* @since 1.16
*
* @param string $output HTML value output
* @param array $entry The GF entry array
* @param array $field_settings Settings for the particular GV field
* @param array $field Current field being displayed
*
* @return String values for this field based on the numeric values used by Gravity Forms
*/
public function get_content($output = '', $entry = array(), $field_settings = array(), $field = array())
{
/** Overridden by a template. */
if (!empty($field['field_path'])) {
return $output;
}
return GVCommon::format_date($field['value'], 'format=' . rgar($field_settings, 'date_display'));
}
示例2: add_edit_view_link
/**
* Add Edit View link when in embedded View
*
* @since 1.13
* @return void
*/
function add_edit_view_link()
{
/** @var WP_Admin_Bar $wp_admin_bar */
global $wp_admin_bar;
if (GVCommon::has_cap('edit_gravityviews')) {
$view_data = GravityView_View_Data::getInstance();
$views = $view_data->get_views();
// If there is a View embed, shor Edit View link.
// todo: Support multiple View embeds with a drop-down menu
if (!$this->gravityview_view->isGravityviewPostType() && !empty($views) && !$view_data->has_multiple_views()) {
$view = reset($views);
if (GVCommon::has_cap('edit_gravityview', $view['id'])) {
$wp_admin_bar->add_menu(array('id' => 'edit-view', 'title' => __('Edit View', 'gravityview'), 'href' => esc_url_raw(admin_url(sprintf('post.php?post=%d&action=edit', $view['id'])))));
}
}
}
}
示例3: add_shortcode_button
/**
* Add shortcode button to the Add Media right
*
* @access public
* @return void
*/
function add_shortcode_button()
{
/**
* @since 1.15.3
*/
if (!GVCommon::has_cap(array('publish_gravityviews'))) {
return;
}
if (!$this->is_post_editor_screen()) {
return;
}
?>
<a href="#TB_inline?width=600&height=800&inlineId=select_gravityview_view" class="thickbox hide-if-no-js button gform_media_link" id="add_gravityview" title="<?php
esc_attr_e("Insert View", 'gravityview');
?>
"><span class="icon gv-icon-astronaut-head"></span><?php
esc_html_e('Add View', 'gravityview');
?>
</a>
<?php
}
示例4: test_fire_everything
/**
* @since 1.15
* @covers GravityView_Uninstall::fire_everything()
*/
function test_fire_everything()
{
$create_count = 10;
$form = $this->factory->form->create_and_get();
$all_forms = GFAPI::get_forms();
$views = $this->factory->view->create_many($create_count, array('form_id' => $form['id']));
$entry_ids = $this->factory->entry->create_many($create_count, array('form_id' => $form['id']));
$connected = gravityview_get_connected_views($form['id']);
$entry_count = GFAPI::count_entries($form['id']);
// Make sure the objects were created and connected
$this->assertEquals($create_count, count(array_filter($views)));
$this->assertEquals($create_count, count(array_filter($connected)));
$this->assertEquals($create_count, count(array_filter($entry_ids)));
$this->_set_up_expected_options();
### DO NOT DELETE WHEN THE USER DOESN'T HAVE THE CAPABILITY
$user = $this->factory->user->create_and_set(array('user_login' => 'administrator', 'user_pass' => 'administrator', 'role' => 'administrator'));
$this->assertTrue(GVCommon::has_cap('gravityview_uninstall'));
### DO NOT DELETE WHEN IT IS NOT SET OR SET TO FALSE
// TRY deleting when the settings aren't configured.
$this->_set_up_gravityview_settings(NULL);
$this->uninstall();
$this->_check_deleted_options(false);
// TRY deleting when the Delete setting is set to No
$this->_set_up_gravityview_settings('0');
$this->uninstall();
$this->_check_deleted_options(false);
### REALLY DELETE NOW
// Create the items
$this->_set_up_gravityview_settings('delete');
$this->_set_up_notes($entry_ids);
$this->_set_up_entry_meta($entry_ids, $form);
$this->uninstall();
// No Forms should be deleted
$this->assertEquals($all_forms, GFAPI::get_forms());
$this->_check_posts();
$this->_check_entries($form, $entry_count);
$this->_check_deleted_options();
$this->_check_deleted_entry_notes($entry_ids);
$this->_check_deleted_entry_meta($entry_ids);
}
示例5: gravityview_get_link
/**
* Generate an HTML anchor tag with a list of supported attributes
*
* @see GVCommon::get_link_html()
*
* @since 1.6
*
* @param string $href URL of the link.
* @param string $anchor_text The text or HTML inside the anchor. This is not sanitized in the function.
* @param array $atts Attributes to be added to the anchor tag
*
* @return string HTML output of anchor link. If empty $href, returns NULL
*/
function gravityview_get_link($href = '', $anchor_text = '', $atts = array())
{
return GVCommon::get_link_html($href, $anchor_text, $atts);
}
示例6: array
$criteria['paging'] = array('offset' => 0, 'page_size' => $view_settings['page_size']);
// Prepare Search Criteria
$criteria['search_criteria'] = array('field_filters' => array(array('key' => 'created_by', 'value' => $created_by, 'operator' => 'is')));
$criteria['search_criteria'] = GravityView_frontend::process_search_only_approved($view_settings, $criteria['search_criteria']);
$criteria['search_criteria']['status'] = apply_filters('gravityview_status', 'active', $view_settings);
/**
* Modify the search parameters before the entries are fetched
*
* @since 1.11
*
* @param array $criteria Gravity Forms search criteria array, as used by GVCommon::get_entries()
* @param array $view_settings Associative array of settings with plugin defaults used if not set by the View
* @param int $form_id The Gravity Forms ID
*/
$criteria = apply_filters('gravityview/field/other_entries/criteria', $criteria, $view_settings, $form_id);
$entries = GVCommon::get_entries($form_id, $criteria);
// Don't show if no entries and the setting says so
if (empty($entries) && $gravityview_view->getCurrentFieldSetting('no_entries_hide')) {
return;
}
// If there are search results, get the entry list object
$list = new GravityView_Entry_List($entries, $gravityview_view->getPostId(), $field['form'], $gravityview_view->getCurrentFieldSetting('link_format'), $gravityview_view->getCurrentFieldSetting('after_link'), 'other_entries');
// Generate and echo the output
$list->output();
/**
* @since 1.7.6
* @deprecated since 1.11
*/
$deprecated = apply_filters('gravityview/field/other_entries/args', array(), $field);
if (!empty($deprecated)) {
_deprecated_function('The "gravityview/field/other_entries/args" filter', 'GravityView 1.11', 'gravityview/field/other_entries/criteria');
示例7: show_approve_entry_column
/**
* Should the Approve/Reject Entry column be shown in the GF Entries page?
*
* @since 1.7.2
*
* @param int $form_id The ID of the Gravity Forms form for which entries are being shown
*
* @return bool True: Show column; False: hide column
*/
private function show_approve_entry_column($form_id)
{
$show_approve_column = GVCommon::has_cap('gravityview_moderate_entries');
/**
* @filter `gravityview/approve_entries/hide-if-no-connections` Return true to hide reject/approve if there are no connected Views
* @since 1.7.2
* @param boolean $hide_if_no_connections
*/
$hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false);
if ($hide_if_no_connections) {
$connected_views = gravityview_get_connected_views($form_id);
if (empty($connected_views)) {
$show_approve_column = false;
}
}
/**
* @filter `gravityview/approve_entries/show-column` Override whether the column is shown
* @param boolean $show_approve_column Whether the column will be shown
* @param int $form_id The ID of the Gravity Forms form for which entries are being shown
*/
$show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id);
return $show_approve_column;
}
示例8: check_user_cap_edit_field
/**
* checks if user has permissions to edit a specific field
*
* Needs to be used combined with GravityView_Edit_Entry::user_can_edit_field for maximum security!!
*
* @param [type] $field [description]
* @return bool
*/
private function check_user_cap_edit_field($field)
{
// If they can edit any entries (as defined in Gravity Forms), we're good.
if (GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_others_entries'))) {
return true;
}
$field_cap = isset($field['allow_edit_cap']) ? $field['allow_edit_cap'] : false;
// If the field has custom editing capaibilities set, check those
if ($field_cap) {
return GVCommon::has_cap($field['allow_edit_cap']);
}
return false;
}
示例9: get_entries
/**
* Get the entries that will be shown in the current widget
*
* @param array $instance Settings for the current widget
*
* @return array $entries Multidimensional array of Gravity Forms entries
*/
private function get_entries($instance, $form_id)
{
// Get the settings for the View ID
$view_settings = gravityview_get_template_settings($instance['view_id']);
// Set the context view ID to avoid conflicts with the Advanced Filter extension.
$criteria['context_view_id'] = $instance['view_id'];
$instance['limit'] = isset($instance['limit']) ? $instance['limit'] : 10;
$view_settings['id'] = $instance['view_id'];
$view_settings['page_size'] = $instance['limit'];
// Prepare paging criteria
$criteria['paging'] = array('offset' => 0, 'page_size' => $instance['limit']);
// Prepare Search Criteria
$criteria['search_criteria'] = array('field_filters' => array());
$criteria['search_criteria'] = GravityView_frontend::process_search_only_approved($view_settings, $criteria['search_criteria']);
$criteria['search_criteria']['status'] = apply_filters('gravityview_status', 'active', $view_settings);
/**
* Modify the search parameters before the entries are fetched
*/
$criteria = apply_filters('gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id);
$results = GVCommon::get_entries($form_id, $criteria);
return $results;
}
示例10: show_for_user
/**
* Check whether to show Support for a user
*
* If the user doesn't have the `gravityview_support_port` capability, returns false.
* If there is no preference set for the user, use the global plugin setting.
*
* @since 1.15
*
* @param int $user Optional. ID of the user to check, defaults to 0 for current user.
*
* @return bool Whether to show GravityView support
*/
public static function show_for_user($user = 0)
{
if (!GVCommon::has_cap('gravityview_support_port')) {
return false;
}
$pref = get_user_option(self::user_pref_name, $user);
// Not set; default to plugin setting
if (false === $pref) {
return GravityView_Settings::getSetting('support_port');
}
return !empty($pref);
}
示例11: check_user_cap_delete_entry
/**
* checks if user has permissions to view the link or delete a specific entry
*
* @since 1.5.1
* @since 1.15 Added `$view_id` param
*
* @param array $entry Gravity Forms entry array
* @param array $field Field settings (optional)
* @param int $view_id Pass a View ID to check caps against. If not set, check against current View (optional)
* @return bool
*/
public static function check_user_cap_delete_entry($entry, $field = array(), $view_id = 0)
{
$gravityview_view = GravityView_View::getInstance();
$current_user = wp_get_current_user();
$entry_id = isset($entry['id']) ? $entry['id'] : NULL;
// Or if they can delete any entries (as defined in Gravity Forms), we're good.
if (GVCommon::has_cap(array('gravityforms_delete_entries', 'gravityview_delete_others_entries'), $entry_id)) {
do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.');
return true;
}
// If field options are passed, check if current user can view the link
if (!empty($field)) {
// If capability is not defined, something is not right!
if (empty($field['allow_edit_cap'])) {
do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Cannot read delete entry field caps', $field);
return false;
}
if (GVCommon::has_cap($field['allow_edit_cap'])) {
// Do not return true if cap is read, as we need to check if the current user created the entry
if ($field['allow_edit_cap'] !== 'read') {
return true;
}
} else {
do_action('gravityview_log_debug', sprintf('GravityView_Delete_Entry[check_user_cap_delete_entry] User %s is not authorized to view delete entry link ', $current_user->ID));
return false;
}
}
if (!isset($entry['created_by'])) {
do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.');
return false;
}
$view_id = empty($view_id) ? $gravityview_view->getViewId() : $view_id;
// Only checks user_delete view option if view is already set
if ($view_id) {
$current_view = gravityview_get_current_view_data($view_id);
$user_delete = isset($current_view['atts']['user_delete']) ? $current_view['atts']['user_delete'] : false;
if (empty($user_delete)) {
do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.');
return false;
}
}
// If the logged-in user is the same as the user who created the entry, we're good.
if (is_user_logged_in() && intval($current_user->ID) === intval($entry['created_by'])) {
do_action('gravityview_log_debug', sprintf('GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID));
return true;
}
return false;
}
示例12: gravityview_get_field_type
/**
* Returns the GF Form field type for a certain field(id) of a form
* @param object $form Gravity Forms form
* @param mixed $field_id Field ID or Field array
* @return string field type
*/
function gravityview_get_field_type($form = null, $field_id = '')
{
return GVCommon::get_field_type($form, $field_id);
}
示例13: app_settings_fields
/**
* Specify the settings fields to be rendered on the plugin settings page
* @return array
*/
public function app_settings_fields()
{
$default_settings = $this->get_default_settings();
$disabled_attribute = GVCommon::has_cap('gravityview_edit_settings') ? false : 'disabled';
$fields = apply_filters('gravityview_settings_fields', array(array('name' => 'license_key', 'required' => true, 'label' => __('License Key', 'gravityview'), 'description' => __('Enter the license key that was sent to you on purchase. This enables plugin updates & support.', 'gravityview') . $this->get_license_handler()->license_details($this->get_app_setting('license_key_response')), 'type' => 'edd_license', 'data-pending-text' => __('Verifying license…', 'gravityview'), 'default_value' => $default_settings['license_key'], 'class' => '' == $this->get_app_setting('license_key') ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key'), array('name' => 'license_key_response', 'default_value' => $default_settings['license_key_response'], 'type' => 'hidden'), array('name' => 'license_key_status', 'default_value' => $default_settings['license_key_status'], 'type' => 'hidden'), array('name' => 'support-email', 'type' => 'text', 'validate' => 'email', 'default_value' => $default_settings['support-email'], 'label' => __('Support Email', 'gravityview'), 'description' => __('In order to provide responses to your support requests, please provide your email address.', 'gravityview'), 'class' => 'code regular-text'), array('name' => 'support_port', 'type' => 'radio', 'label' => __('Show Support Port?', 'gravityview'), 'default_value' => $default_settings['support_port'], 'horizontal' => 1, 'choices' => array(array('label' => _x('Show', 'Setting: Show or Hide', 'gravityview'), 'value' => '1'), array('label' => _x('Hide', 'Setting: Show or Hide', 'gravityview'), 'value' => '0')), 'tooltip' => '<p><img src="' . esc_url_raw(plugins_url('assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE)) . '" alt="' . esc_attr__('The Support Port looks like this.', 'gravityview') . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview') . '</p>', 'description' => __('Show the Support Port on GravityView pages?', 'gravityview')), array('name' => 'no-conflict-mode', 'type' => 'radio', 'label' => __('No-Conflict Mode', 'gravityview'), 'default_value' => $default_settings['no-conflict-mode'], 'horizontal' => 1, 'choices' => array(array('label' => _x('On', 'Setting: On or off', 'gravityview'), 'value' => '1'), array('label' => _x('Off', 'Setting: On or off', 'gravityview'), 'value' => '0')), 'description' => __('Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview') . ' ' . __('If your Edit View tabs are ugly, enable this setting.', 'gravityview')), array('name' => 'delete-on-uninstall', 'type' => 'radio', 'label' => __('Remove Data on Delete?', 'gravityview'), 'default_value' => $default_settings['delete-on-uninstall'], 'horizontal' => 1, 'choices' => array(array('label' => _x('Keep GravityView Data', 'Setting: what to do when uninstalling plugin', 'gravityview'), 'value' => '0', 'tooltip' => sprintf('<h6>%s</h6><p>%s</p>', __('Keep GravityView content and settings', 'gravityview'), __('If you delete then re-install the plugin, all GravityView data will be kept. Views, settings, etc. will be untouched.', 'gravityview'))), array('label' => _x('Permanently Delete', 'Setting: what to do when uninstalling plugin', 'gravityview'), 'value' => 'delete', 'tooltip' => sprintf('<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __('Delete all GravityView content and settings', 'gravityview'), __('If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview'), __('When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview')))), 'description' => sprintf(__('Should GravityView content and entry approval status be removed from the site when the GravityView plugin is deleted?', 'gravityview'), __('Permanently Delete', 'gravityview')))));
/**
* Redux backward compatibility
* @since 1.7.4
*/
foreach ($fields as &$field) {
$field['name'] = isset($field['name']) ? $field['name'] : rgget('id', $field);
$field['label'] = isset($field['label']) ? $field['label'] : rgget('title', $field);
$field['default_value'] = isset($field['default_value']) ? $field['default_value'] : rgget('default', $field);
$field['description'] = isset($field['description']) ? $field['description'] : rgget('subtitle', $field);
if ($disabled_attribute) {
$field['disabled'] = $disabled_attribute;
}
}
$sections = array(array('description' => sprintf('<span class="version-info description">%s</span>', sprintf(__('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version)), 'fields' => $fields));
// custom 'update settings' button
$button = array('class' => 'button button-primary button-hero', 'type' => 'save');
if ($disabled_attribute) {
$button['disabled'] = $disabled_attribute;
}
/**
* @filter `gravityview/settings/extension/sections` Modify the GravityView settings page
* Extensions can tap in here to insert their own section and settings.
* <code>
* $sections[] = array(
* 'title' => __( 'GravityView My Extension Settings', 'gravityview' ),
* 'fields' => $settings,
* );
* </code>
* @param array $extension_settings Empty array, ready for extension settings!
*/
$extension_sections = apply_filters('gravityview/settings/extension/sections', array());
// If there are extensions, add a section for them
if (!empty($extension_sections)) {
if ($disabled_attribute) {
foreach ($extension_sections as &$section) {
foreach ($section['fields'] as &$field) {
$field['disabled'] = $disabled_attribute;
}
}
}
$k = count($extension_sections) - 1;
$extension_sections[$k]['fields'][] = $button;
$sections = array_merge($sections, $extension_sections);
} else {
// add the 'update settings' button to the general section
$sections[0]['fields'][] = $button;
}
return $sections;
}
示例14: current_user_can_copy
/**
* Test if the user is allowed to copy Views
*
* @since 1.6
*/
private function current_user_can_copy($post)
{
$id = is_object($post) ? $post->ID : $post;
// Can't edit this current View
return GVCommon::has_cap('copy_gravityviews', $id);
}
示例15: license_call
/**
* Perform the call to EDD based on the AJAX call or passed data
*
* @since 1.7.4
*
* @param array $array {
* @type string $license The license key
* @type string $edd_action The EDD action to perform, like `check_license`
* @type string $field_id The ID of the field to check
* @type boolean $update Whether to update plugin settings. Prevent updating the data by setting an `update` key to false
* @type string $format If `object`, return the object of the license data. Else, return the JSON-encoded object
* }
*
* @return mixed|string|void
*/
public function license_call($array = array())
{
$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
$data = empty($array) ? $_POST['data'] : $array;
$has_cap = GVCommon::has_cap('gravityview_edit_settings');
if ($is_ajax && empty($data['license'])) {
die(-1);
}
// If the user isn't allowed to edit settings, show an error message
if (!$has_cap) {
$license_data = new stdClass();
$license_data->error = 'capability';
$license_data->message = $this->get_license_message($license_data);
$json = json_encode($license_data);
} else {
$license = esc_attr(rgget('license', $data));
$license_data = $this->_license_get_remote_response($data, $license);
// Empty is returned when there's an error.
if (empty($license_data)) {
if ($is_ajax) {
exit(json_encode(array()));
} else {
// Non-ajax call
return json_encode(array());
}
}
$license_data->message = $this->get_license_message($license_data);
$json = json_encode($license_data);
$update_license = !isset($data['update']) || !empty($data['update']);
$is_check_action_button = 'check_license' === $data['edd_action'] && defined('DOING_AJAX') && DOING_AJAX;
// Failed is the response from trying to de-activate a license and it didn't work.
// This likely happened because people entered in a different key and clicked "Deactivate",
// meaning to deactivate the original key. We don't want to save this response, since it is
// most likely a mistake.
if ($license_data->license !== 'failed' && !$is_check_action_button && $update_license) {
if (!empty($data['field_id'])) {
set_transient('gravityview_' . esc_attr($data['field_id']) . '_valid', $license_data, DAY_IN_SECONDS);
}
$this->license_call_update_settings($license_data, $data);
}
}
// End $has_cap
if ($is_ajax) {
exit($json);
} else {
// Non-ajax call
return rgget('format', $data) === 'object' ? $license_data : $json;
}
}