本文整理汇总了PHP中gravityview_get_link函数的典型用法代码示例。如果您正苦于以下问题:PHP gravityview_get_link函数的具体用法?PHP gravityview_get_link怎么用?PHP gravityview_get_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gravityview_get_link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extract
<?php
/**
* Display the website field type
*
* @package GravityView
* @subpackage GravityView/templates/fields
*/
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
if (!empty($value) && function_exists('gravityview_format_link')) {
/** @since 1.8 */
$anchor_text = !empty($field_settings['anchor_text']) ? trim(rtrim($field_settings['anchor_text'])) : false;
// Check empty again, just in case trim removed whitespace didn't work
if (!empty($anchor_text)) {
// Replace the variables
$anchor_text = GravityView_API::replace_variables($anchor_text, $form, $entry);
} else {
$anchor_text = empty($field_settings['truncatelink']) ? $value : gravityview_format_link($value);
}
$attributes = empty($field_settings['open_same_window']) ? 'target=_blank' : '';
echo gravityview_get_link($value, $anchor_text, $attributes);
} else {
echo $display_value;
}
示例2: shortcode
/**
* @param array $atts {
* @type string $view_id Define the ID for the View where the entry will
* @type string $entry_id ID of the entry to edit. If undefined, uses the current entry ID
* @type string $post_id ID of the base post or page to use for an embedded View
* @type string $link_atts Whether to open Edit Entry link in a new window or the same window
* @type string $return What should the shortcode return: link HTML (`html`) or the URL (`url`). Default: `html`
* @type string $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
* }
* @param string $content
* @param string $context
*
* @return string|void
*/
public function shortcode($atts = array(), $content = '', $context = 'gv_edit_entry')
{
// Make sure GV is loaded
if (!class_exists('GravityView_frontend') || !class_exists('GravityView_View')) {
return null;
}
$defaults = array('view_id' => 0, 'entry_id' => 0, 'post_id' => 0, 'link_atts' => '', 'return' => 'html', 'field_values' => '');
$settings = shortcode_atts($defaults, $atts, $context);
if (empty($settings['view_id'])) {
$view_id = GravityView_View::getInstance()->getViewId();
} else {
$view_id = absint($settings['view_id']);
}
if (empty($view_id)) {
do_action('gravityview_log_debug', __METHOD__ . ' A View ID was not defined');
return null;
}
$post_id = empty($settings['post_id']) ? $view_id : absint($settings['post_id']);
$form_id = gravityview_get_form_id($view_id);
$backup_entry_id = GravityView_frontend::getInstance()->getSingleEntry() ? GravityView_frontend::getInstance()->getSingleEntry() : GravityView_View::getInstance()->getCurrentEntry();
$entry_id = empty($settings['entry_id']) ? $backup_entry_id : absint($settings['entry_id']);
if (empty($entry_id)) {
do_action('gravityview_log_debug', __METHOD__ . ' No entry defined');
return null;
}
// By default, show only current user
$user = wp_get_current_user();
if (!$user) {
do_action('gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user');
return null;
}
$entry = $this->get_entry($entry_id, $form_id);
// No search results
if (false === $entry) {
do_action('gravityview_log_debug', __METHOD__ . ' No entries match the entry ID defined', $entry_id);
return null;
}
// Check permissions
if (false === GravityView_Edit_Entry::check_user_cap_edit_entry($entry, $view_id)) {
do_action('gravityview_log_debug', __METHOD__ . ' User does not have the capability to edit this entry: ' . $entry_id);
return null;
}
$href = GravityView_Delete_Entry::get_delete_link($entry, $view_id, $post_id, $settings);
// Get just the URL, not the tag
if ('url' === $settings['return']) {
return $href;
}
$link_text = empty($content) ? __('Delete Entry', 'gravityview') : $content;
return gravityview_get_link($href, $link_text, $settings['link_atts']);
}
示例3: get_files_array
//.........这里部分代码省略.........
* @filter `gravityview_audio_settings` Modify the settings passed to the `wp_video_shortcode()` function
* @since 1.2
* @param array $audio_settings Array with `src` and `class` keys
*/
$audio_settings = apply_filters('gravityview_audio_settings', array('src' => $file_path, 'class' => 'wp-audio-shortcode gv-audio gv-field-id-' . $field_settings['id']));
/**
* Generate the audio shortcode
* @see http://codex.wordpress.org/Audio_Shortcode
* @see https://developer.wordpress.org/reference/functions/wp_audio_shortcode/
*/
$content = wp_audio_shortcode($audio_settings);
}
break;
// Video file
// Video file
case in_array($extension, wp_get_video_extensions()):
$disable_lightbox = true;
if (shortcode_exists('video')) {
$disable_wrapped_link = true;
/**
* @filter `gravityview_video_settings` Modify the settings passed to the `wp_video_shortcode()` function
* @since 1.2
* @param array $video_settings Array with `src` and `class` keys
*/
$video_settings = apply_filters('gravityview_video_settings', array('src' => $file_path, 'class' => 'wp-video-shortcode gv-video gv-field-id-' . $field_settings['id']));
/**
* Generate the video shortcode
* @see http://codex.wordpress.org/Video_Shortcode
* @see https://developer.wordpress.org/reference/functions/wp_video_shortcode/
*/
$content = wp_video_shortcode($video_settings);
}
break;
// PDF
// PDF
case $extension === 'pdf':
// PDF needs to be displayed in an IFRAME
$link = add_query_arg(array('TB_iframe' => 'true'), $link);
break;
// if not image, do not set the lightbox (@since 1.5.3)
// if not image, do not set the lightbox (@since 1.5.3)
case !in_array($extension, array('jpg', 'jpeg', 'jpe', 'gif', 'png')):
$disable_lightbox = true;
break;
}
// If using Link to File, override the content.
// (We do this here so that the $disable_lightbox can be set. Yes, there's a little more processing time, but oh well.)
if (!empty($field_settings['link_to_file'])) {
// Force the content to be the file name
$content = $file_path_info["basename"];
// Restore the wrapped link
$disable_wrapped_link = false;
}
// Whether to use lightbox or not
if ($disable_lightbox || empty($gravityview_view->atts['lightbox']) || !empty($field_settings['show_as_link'])) {
$link_atts = empty($field_settings['show_as_link']) ? array('target' => '_blank') : array();
} else {
$link_atts = array('rel' => sprintf("%s-%s", $gv_class, $entry['id']), 'target' => '_blank', 'class' => 'thickbox');
}
/**
* @filter `gravityview/fields/fileupload/link_atts` Modify the link attributes for a file upload field
* @param array|string $link_atts Array or attributes string
* @param array $field Current GravityView field array
*/
$link_atts = apply_filters('gravityview/fields/fileupload/link_atts', $link_atts, $gravityview_view->getCurrentField());
/**
* @filter `gravityview/fields/fileupload/disable_link` Filter to alter the default behaviour of wrapping images (or image names) with a link to the content object
* @since 1.5.1
* @param bool $disable_wrapped_link whether to wrap the content with a link to the content object.
* @param array $gravityview_view->field_data
* @see GravityView_API:field_value() for info about $gravityview_view->field_data
*/
$disable_wrapped_link = apply_filters('gravityview/fields/fileupload/disable_link', $disable_wrapped_link, $gravityview_view->getCurrentField());
// If the HTML output hasn't been overridden by the switch statement above, use the default format
if (!empty($content) && empty($disable_wrapped_link)) {
/**
* Modify the link text (defaults to the file name)
*
* @since 1.7
*
* @param string $content The existing anchor content. Could be `<img>` tag, audio/video embed or the file name
* @param array $field GravityView array of the current field being processed
*/
$content = apply_filters('gravityview/fields/fileupload/link_content', $content, $gravityview_view->getCurrentField());
$content = gravityview_get_link($link, $content, $link_atts);
}
$output_arr[] = array('file_path' => $file_path, 'content' => $content);
}
// End foreach loop
/**
* @filter `gravityview/fields/fileupload/files_array` Modify the files array
* @since 1.7
* @param array $output_arr Associative array of files \n
* @type string $file_path The path to the file as stored in Gravity Forms \n
* @type string $content The generated output for the file \n
* @param array $field GravityView array of the current field being processed
*/
$output_arr = apply_filters('gravityview/fields/fileupload/files_array', $output_arr, $gravityview_view->getCurrentField());
return $output_arr;
}
示例4: extract
<?php
/**
* Display the post_title field type
*
* @package GravityView
* @subpackage GravityView/templates/fields
*/
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
if (!empty($field_settings['dynamic_data']) && !empty($entry['post_id'])) {
$output = get_the_title($entry['post_id']);
if (empty($output)) {
do_action('gravityview_log_debug', 'Dynamic data for post #' . $entry['post_id'] . ' doesnt exist.');
}
} else {
$output = $display_value;
}
// Link to the post URL?
if (!empty($field_settings['link_to_post']) && !empty($entry['post_id'])) {
echo gravityview_get_link(get_permalink($entry['post_id']), esc_attr($output));
} else {
echo $output;
}
示例5: the_clear_search_button
/**
* Output the Clear Search Results button
* @since 1.5.4
*/
public static function the_clear_search_button()
{
$gravityview_view = GravityView_View::getInstance();
if ($gravityview_view->search_clear) {
$url = strtok(add_query_arg(array()), '?');
echo gravityview_get_link($url, esc_html__('Clear', 'gravityview'), 'class=button gv-search-clear');
}
}
示例6: get_connected_form_links
/**
* Get HTML links relating to a connected form, like Edit, Entries, Settings, Preview
* @param array|int $form Gravity Forms forms array, or the form ID
* @param boolean $include_form_link Whether to include the bold name of the form in the output
* @return string HTML links
*/
public static function get_connected_form_links($form, $include_form_link = true)
{
// Either the form is empty or the form ID is 0, not yet set.
if (empty($form)) {
return '';
}
// The $form is passed as the form ID
if (!is_array($form)) {
$form = gravityview_get_form($form);
}
$form_id = $form['id'];
$links = array();
if (GVCommon::has_cap('gravityforms_edit_forms')) {
$form_url = admin_url(sprintf('admin.php?page=gf_edit_forms&id=%d', $form_id));
$form_link = '<strong class="gv-form-title">' . gravityview_get_link($form_url, $form['title'], 'class=row-title') . '</strong>';
$links[] = '<span>' . gravityview_get_link($form_url, __('Edit Form', 'gravityview')) . '</span>';
} else {
$form_link = '<strong class="gv-form-title">' . esc_html($form['title']) . '</strong>';
}
if (GVCommon::has_cap('gravityforms_view_entries')) {
$entries_url = admin_url(sprintf('admin.php?page=gf_entries&id=%d', $form_id));
$links[] = '<span>' . gravityview_get_link($entries_url, __('Entries', 'gravityview')) . '</span>';
}
if (GVCommon::has_cap(array('gravityforms_edit_settings', 'gravityview_view_settings'))) {
$settings_url = admin_url(sprintf('admin.php?page=gf_edit_forms&view=settings&id=%d', $form_id));
$links[] = '<span>' . gravityview_get_link($settings_url, __('Settings', 'gravityview'), 'title=' . __('Edit settings for this form', 'gravityview')) . '</span>';
}
if (GVCommon::has_cap(array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms"))) {
$preview_url = site_url(sprintf('?gf_page=preview&id=%d', $form_id));
$links[] = '<span>' . gravityview_get_link($preview_url, __('Preview Form', 'gravityview'), 'title=' . __('Preview this form', 'gravityview')) . '</span>';
}
$output = '';
if (!empty($include_form_link)) {
$output .= $form_link;
}
/**
* @filter `gravityview_connected_form_links` Modify the links shown in the Connected Form links
* @since 1.6
* @param array $links Links to show
* @param array $form Gravity Forms form array
*/
$links = apply_filters('gravityview_connected_form_links', $links, $form);
$output .= '<div class="row-actions">' . implode(' | ', $links) . '</div>';
return $output;
}
示例7: entry_link_html
/**
* Generate an anchor tag that links to an entry.
*
* @since 1.6
*
* @param string $anchor_text The text or HTML inside the link
* @param array $entry Gravity Forms entry array
* @param array $field_settings Array of field settings. Optional, but passed to the `gravityview_field_entry_link` filter
*/
public static function entry_link_html($entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array())
{
if (empty($entry) || !is_array($entry) || !isset($entry['id'])) {
do_action('gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry);
return NULL;
}
$href = self::entry_link($entry);
$link = gravityview_get_link($href, $anchor_text, $passed_tag_atts);
/**
* @filter `gravityview_field_entry_link` Modify the link HTML
* @param string $link HTML output of the link
* @param string $href URL of the link
* @param array $entry The GF entry array
* @param array $field_settings Settings for the particular GV field
*/
$output = apply_filters('gravityview_field_entry_link', $link, $href, $entry, $field_settings);
return $output;
}
示例8: extract
<?php
/**
* Generate output for the Source URL field
* @package GravityView
* @subpackage GravityView/templates/fields
* @since 1.1.6
*/
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
// If linking to the source URL
if (!empty($field_settings['link_to_source'])) {
// If customizing the anchor text
if (!empty($field_settings['source_link_text'])) {
$link_text = GravityView_API::replace_variables($field_settings['source_link_text'], $form, $entry);
} else {
// Otherwise, it's just the URL
$link_text = $value;
}
$output = gravityview_get_link($value, esc_html($link_text));
} else {
// Otherwise, it's just the URL
$output = $value;
}
echo $output;
示例9: make_duplicate_link_row
/**
* Add the link to action list for post_row_actions
*
* @since 1.6
* @param array $actions Row action links. Defaults are 'Edit', 'Quick Edit', 'Restore, 'Trash', 'Delete Permanently', 'Preview', and 'View'
* @param WP_Post $post
*/
public function make_duplicate_link_row($actions, $post)
{
// Only process on GravityView Views
if (get_post_type($post) === 'gravityview' && $this->current_user_can_copy($post)) {
$clone_link = $this->get_clone_view_link($post->ID, 'display', false);
$clone_text = __('Clone', 'gravityview');
$clone_title = __('Clone this View', 'gravityview');
$actions['clone'] = gravityview_get_link($clone_link, $clone_text, 'title=' . $clone_title);
$clone_draft_link = $this->get_clone_view_link($post->ID);
$clone_draft_text = $this->is_all_views_page() ? __('New Draft', 'gravityview') : __('Clone View', 'gravityview');
$clone_draft_title = __('Copy as a new draft View', 'gravityview');
$actions['edit_as_new_draft'] = gravityview_get_link($clone_draft_link, esc_html($clone_draft_text), 'title=' . $clone_draft_title);
}
return $actions;
}
示例10: shortcode
/**
* Generate a link to an entry. The link can be an edit, delete, or standard link.
*
* @since 1.15
*
* @param array $atts {
* @type string $action What type of link to generate. Options: `read`, `edit`, and `delete`. Default: `read`
* @type string $view_id Define the ID for the View. If not set, use current View ID, if exists.
* @type string $entry_id ID of the entry to edit. If undefined, uses the current entry ID, if exists.
* @type string $post_id ID of the base post or page to use for an embedded View
* @type string $link_atts Pass anchor tag attributes (`target=_blank` to open Edit Entry link in a new window, for example)
* @type string $return What should the shortcode return: link HTML (`html`) or the URL (`url`). Default: `html`
* @type string $field_values Only used for `action="edit"`. Parameters to pass in to the prefill data in Edit Entry form. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
* }
*
* @param string|null $content Used as link anchor text, if specified.
* @param string $context Current shortcode being called. Not used.
*
* @return null|string If admin or an error occurred, returns null. Otherwise, returns entry link output. If `$atts['return']` is 'url', the entry link URL. Otherwise, entry link `<a>` HTML tag.
*/
private function shortcode($atts, $content = null, $context = 'gv_entry_link')
{
// Don't process when saving post. Keep processing if it's admin-ajax.php
if (!class_exists('GravityView_Plugin') || GravityView_Plugin::is_admin()) {
return null;
}
// Make sure GV is loaded
if (!class_exists('GravityView_frontend') || !class_exists('GravityView_View')) {
do_action('gravityview_log_error', __METHOD__ . ' GravityView_frontend or GravityView_View do not exist.');
return null;
}
$this->settings = shortcode_atts(self::$defaults, $atts, $context);
$this->view_id = empty($this->settings['view_id']) ? GravityView_View::getInstance()->getViewId() : absint($this->settings['view_id']);
if (empty($this->view_id)) {
do_action('gravityview_log_error', __METHOD__ . ' A View ID was not defined and we are not inside a View');
return null;
}
$this->entry = $this->get_entry($this->settings['entry_id']);
do_action('gravityview_log_debug', __METHOD__ . ' ' . $context . ' $atts: ', $atts);
if (!$this->has_cap()) {
do_action('gravityview_log_error', __METHOD__ . ' User does not have the capability to ' . esc_attr($this->settings['action']) . ' this entry: ' . $this->entry['id']);
return null;
}
$url = $this->get_url();
if (!$url) {
do_action('gravityview_log_error', __METHOD__ . ' Link returned false; View or Post may not exist.');
return false;
}
// Get just the URL, not the tag
if ('url' === $this->settings['return']) {
return $url;
}
$link_atts = $this->get_link_atts();
$link_text = $this->get_anchor_text($content);
return gravityview_get_link($url, $link_text, $link_atts);
}
示例11: is_valid_embed_id
/**
* Checks if the passed post id has the passed View id embedded.
*
* Returns
*
* @since 1.6.1
*
* @param string $post_id Post ID where the View is embedded
* @param string $view_id View ID
*
* @return bool|WP_Error If valid, returns true. If invalid, returns WP_Error containing error message.
*/
public static function is_valid_embed_id($post_id = '', $view_id = '', $empty_is_valid = true)
{
$message = NULL;
// Not invalid if not set!
if (empty($post_id) || empty($view_id)) {
if ($empty_is_valid) {
return true;
}
$message = esc_html__('The ID is required.', 'gravityview');
}
if (!$message) {
$status = get_post_status($post_id);
// Nothing exists with that post ID.
if (!is_numeric($post_id)) {
$message = esc_html__('You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview');
// @todo Convert to generic article about Embed IDs
$message .= ' ' . gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview'), 'target=_blank');
}
}
if (!$message) {
// Nothing exists with that post ID.
if (empty($status) || in_array($status, array('revision', 'attachment'))) {
$message = esc_html__('There is no post or page with that ID.', 'gravityview');
}
}
if (!$message) {
$view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id($post_id);
// The post or page specified does not contain the shortcode.
if (false === in_array($view_id, (array) $view_ids_in_post)) {
$message = sprintf(esc_html__('The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview'), '<br /><code>[gravityview id="' . intval($view_id) . '"]</code>');
}
}
if (!$message) {
// It's a View
if ('gravityview' === get_post_type($post_id)) {
$message = esc_html__('The ID is already a View.', 'gravityview');
}
}
if ($message) {
return new WP_Error('invalid_embed_id', $message);
}
return true;
}
示例12: extract
<?php
$gravityview_view = GravityView_View::getInstance();
$view_id = $gravityview_view->getViewId();
extract($gravityview_view->getCurrentField());
// Only show the link to logged-in users with the rigth caps.
if (!GravityView_Delete_Entry::check_user_cap_delete_entry($entry, $field_settings)) {
return;
}
$link_text = empty($field_settings['delete_link']) ? __('Delete Entry', 'gravityview') : $field_settings['delete_link'];
$link_text = apply_filters('gravityview_entry_link', GravityView_API::replace_variables($link_text, $form, $entry));
$href = GravityView_Delete_Entry::get_delete_link($entry, $view_id);
$attributes = array('onclick' => GravityView_Delete_Entry::get_confirm_dialog());
echo gravityview_get_link($href, $link_text, $attributes);
示例13: extract
<?php
/**
* Display the post_id field type
*
* @package GravityView
* @subpackage GravityView/templates/fields
*/
$gravityview_view = GravityView_View::getInstance();
extract($gravityview_view->getCurrentField());
// Link to the post URL?
if ($gravityview_view->getCurrentFieldSetting('link_to_post') && !empty($entry['post_id'])) {
echo gravityview_get_link(get_permalink($entry['post_id']), esc_attr($display_value));
} else {
echo $display_value;
}
示例14: extract
<?php
$gravityview_view = GravityView_View::getInstance();
$view_id = $gravityview_view->getViewId();
extract($gravityview_view->getCurrentField());
// Only show the link to logged-in users.
if (!GravityView_Edit_Entry::check_user_cap_edit_entry($entry)) {
return;
}
$link_text = empty($field_settings['edit_link']) ? __('Edit Entry', 'gravityview') : $field_settings['edit_link'];
$link_atts = empty($field_settings['new_window']) ? '' : 'target="_blank"';
$output = apply_filters('gravityview_entry_link', GravityView_API::replace_variables($link_text, $form, $entry));
$href = GravityView_Edit_Entry::get_edit_link($entry, $view_id);
echo gravityview_get_link($href, $output, $link_atts);
示例15: form
//.........这里部分代码省略.........
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($instance['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…', 'gravityview'), 'target=_blank');
?>
</span>
</p>
<p>
<label for="<?php
echo $this->get_field_id('limit');
?>
">
<span><?php
_e('Number of entries to show:', 'gravityview');
?>
</span>
</label>
<input class="code" id="<?php
echo $this->get_field_id('limit');
?>
" name="<?php
echo $this->get_field_name('limit');
?>
" type="number" value="<?php
echo intval($instance['limit']);
?>
" size="3" />
</p>
<p>
<label for="<?php
echo $this->get_field_id('link_format');
?>
">
<span><?php