@@ -4,7 +4,9 @@ |
||
| 4 | 4 | //set_site_transient( 'update_plugins', null ); |
| 5 | 5 | |
| 6 | 6 | // Exit if accessed directly |
| 7 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 7 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 8 | + exit; |
|
| 9 | +} |
|
| 8 | 10 | |
| 9 | 11 | /** |
| 10 | 12 | * Allows plugins to use their own update API. |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 15 | +if (!defined('ABSPATH')) exit; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * GravityView_Welcome Class |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | * @since 1.0 |
| 35 | 35 | */ |
| 36 | 36 | public function __construct() { |
| 37 | - add_action( 'admin_menu', array( $this, 'admin_menus'), 200 ); |
|
| 38 | - add_action( 'admin_head', array( $this, 'admin_head' ) ); |
|
| 39 | - add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
| 40 | - add_filter( 'gravityview_is_admin_page', array( $this, 'is_dashboard_page'), 10, 2 ); |
|
| 37 | + add_action('admin_menu', array($this, 'admin_menus'), 200); |
|
| 38 | + add_action('admin_head', array($this, 'admin_head')); |
|
| 39 | + add_action('admin_init', array($this, 'welcome')); |
|
| 40 | + add_filter('gravityview_is_admin_page', array($this, 'is_dashboard_page'), 10, 2); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -57,27 +57,27 @@ discard block |
||
| 57 | 57 | __('Getting Started', 'gravityview'), |
| 58 | 58 | $this->minimum_capability, |
| 59 | 59 | 'gv-getting-started', |
| 60 | - array( $this, 'getting_started_screen' ) |
|
| 60 | + array($this, 'getting_started_screen') |
|
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | 63 | // Changelog Page |
| 64 | 64 | add_submenu_page( |
| 65 | 65 | 'edit.php?post_type=gravityview', |
| 66 | - __( 'Changelog', 'gravityview' ), |
|
| 67 | - __( 'Changelog', 'gravityview' ), |
|
| 66 | + __('Changelog', 'gravityview'), |
|
| 67 | + __('Changelog', 'gravityview'), |
|
| 68 | 68 | $this->minimum_capability, |
| 69 | 69 | 'gv-changelog', |
| 70 | - array( $this, 'changelog_screen' ) |
|
| 70 | + array($this, 'changelog_screen') |
|
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | 73 | // Credits Page |
| 74 | 74 | add_submenu_page( |
| 75 | 75 | 'edit.php?post_type=gravityview', |
| 76 | - __( 'Credits', 'gravityview' ), |
|
| 77 | - __( 'Credits', 'gravityview' ), |
|
| 76 | + __('Credits', 'gravityview'), |
|
| 77 | + __('Credits', 'gravityview'), |
|
| 78 | 78 | $this->minimum_capability, |
| 79 | 79 | 'gv-credits', |
| 80 | - array( $this, 'credits_screen' ) |
|
| 80 | + array($this, 'credits_screen') |
|
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | 83 | } |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | public function is_dashboard_page($is_page = false, $hook = NULL) { |
| 91 | 91 | global $plugin_page; |
| 92 | 92 | |
| 93 | - if($is_page) { return $is_page; } |
|
| 93 | + if ($is_page) { return $is_page; } |
|
| 94 | 94 | |
| 95 | - return in_array( $plugin_page, array( 'gv-about', 'gv-credits', 'gv-getting-started' ) ); |
|
| 95 | + return in_array($plugin_page, array('gv-about', 'gv-credits', 'gv-getting-started')); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | public function admin_head() { |
| 106 | 106 | global $plugin_page; |
| 107 | 107 | |
| 108 | - remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-credits' ); |
|
| 109 | - remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-changelog' ); |
|
| 108 | + remove_submenu_page('edit.php?post_type=gravityview', 'gv-credits'); |
|
| 109 | + remove_submenu_page('edit.php?post_type=gravityview', 'gv-changelog'); |
|
| 110 | 110 | |
| 111 | - if( !$this->is_dashboard_page() ) { return; } |
|
| 111 | + if (!$this->is_dashboard_page()) { return; } |
|
| 112 | 112 | |
| 113 | 113 | ?> |
| 114 | 114 | <style type="text/css" media="screen"> |
@@ -139,23 +139,23 @@ discard block |
||
| 139 | 139 | global $plugin_page; |
| 140 | 140 | |
| 141 | 141 | // Don't fetch -beta, etc. |
| 142 | - list( $display_version ) = explode( '-', GravityView_Plugin::version ); |
|
| 142 | + list($display_version) = explode('-', GravityView_Plugin::version); |
|
| 143 | 143 | |
| 144 | - $selected = !empty( $plugin_page ) ? $plugin_page : 'gv-getting-started'; |
|
| 144 | + $selected = !empty($plugin_page) ? $plugin_page : 'gv-getting-started'; |
|
| 145 | 145 | ?> |
| 146 | 146 | |
| 147 | - <h1><img class="alignleft" src="<?php echo plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ); ?>" width="100" height="132" /><?php printf( esc_html__( 'Welcome to GravityView %s', 'gravityview' ), $display_version ); ?></h1> |
|
| 148 | - <div class="about-text"><?php esc_html_e( 'Thank you for installing GravityView. Beautifully display your Gravity Forms entries.', 'gravityview' ); ?></div> |
|
| 147 | + <h1><img class="alignleft" src="<?php echo plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE); ?>" width="100" height="132" /><?php printf(esc_html__('Welcome to GravityView %s', 'gravityview'), $display_version); ?></h1> |
|
| 148 | + <div class="about-text"><?php esc_html_e('Thank you for installing GravityView. Beautifully display your Gravity Forms entries.', 'gravityview'); ?></div> |
|
| 149 | 149 | |
| 150 | 150 | <h2 class="nav-tab-wrapper clear"> |
| 151 | - <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-getting-started', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
| 152 | - <?php _e( "Getting Started", 'gravityview' ); ?> |
|
| 151 | + <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'gv-getting-started', 'post_type' => 'gravityview'), 'edit.php'))); ?>"> |
|
| 152 | + <?php _e("Getting Started", 'gravityview'); ?> |
|
| 153 | 153 | </a> |
| 154 | - <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-changelog', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
| 155 | - <?php _e( "List of Changes", 'gravityview' ); ?> |
|
| 154 | + <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'gv-changelog', 'post_type' => 'gravityview'), 'edit.php'))); ?>"> |
|
| 155 | + <?php _e("List of Changes", 'gravityview'); ?> |
|
| 156 | 156 | </a> |
| 157 | - <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-credits', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
| 158 | - <?php _e( 'Credits', 'gravityview' ); ?> |
|
| 157 | + <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'gv-credits', 'post_type' => 'gravityview'), 'edit.php'))); ?>"> |
|
| 158 | + <?php _e('Credits', 'gravityview'); ?> |
|
| 159 | 159 | </a> |
| 160 | 160 | </h2> |
| 161 | 161 | <?php |
@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | <div class="last-feature"> |
| 207 | 207 | <h2>Embed Views in Posts & Pages</h2> |
| 208 | - <p><img src="<?php echo plugins_url( 'assets/images/screenshots/add-view-button.png', GRAVITYVIEW_FILE ); ?>" class="gv-welcome-screenshots" height="35" width="97" />Views don’t need to be embedded in a post or page, but you can if you want. Embed Views using the "Add View" button above your content editor.</p> |
|
| 208 | + <p><img src="<?php echo plugins_url('assets/images/screenshots/add-view-button.png', GRAVITYVIEW_FILE); ?>" class="gv-welcome-screenshots" height="35" width="97" />Views don’t need to be embedded in a post or page, but you can if you want. Embed Views using the "Add View" button above your content editor.</p> |
|
| 209 | 209 | </div> |
| 210 | 210 | |
| 211 | 211 | </div> |
| 212 | 212 | |
| 213 | 213 | <div class="feature-section clear"> |
| 214 | 214 | <h2>Configure Multiple Entry, Single Entry, and Edit Entry Layouts</h2> |
| 215 | - <p><img src="<?php echo plugins_url( 'assets/images/screenshots/add-field.png', GRAVITYVIEW_FILE ); ?>" alt="Add a field dialog box" class="gv-welcome-screenshots" />You can configure what fields are displayed in <strong>Multiple Entry</strong>, <strong>Single Entry</strong>, and <strong>Edit Entry</strong> modes. These can be configured by clicking on the tabs in "View Configuration."</p> |
|
| 215 | + <p><img src="<?php echo plugins_url('assets/images/screenshots/add-field.png', GRAVITYVIEW_FILE); ?>" alt="Add a field dialog box" class="gv-welcome-screenshots" />You can configure what fields are displayed in <strong>Multiple Entry</strong>, <strong>Single Entry</strong>, and <strong>Edit Entry</strong> modes. These can be configured by clicking on the tabs in "View Configuration."</p> |
|
| 216 | 216 | |
| 217 | 217 | <ul class="ul-disc"> |
| 218 | 218 | <li>Click "+ Add Field" to add a field to a zone</li> |
@@ -256,13 +256,13 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | <div class="feature-section col two-col" style="margin:0; padding: 0;"> |
| 258 | 258 | <div class="col col-1"> |
| 259 | - <div class="media-container" style="min-height:81px; border: none;"><img src="<?php echo plugins_url( 'assets/images/screenshots/pricing-merge-tags.jpg', GRAVITYVIEW_FILE ); ?>" alt="Pricing merge tags"></div> |
|
| 259 | + <div class="media-container" style="min-height:81px; border: none;"><img src="<?php echo plugins_url('assets/images/screenshots/pricing-merge-tags.jpg', GRAVITYVIEW_FILE); ?>" alt="Pricing merge tags"></div> |
|
| 260 | 260 | <h4 class="higher">Pricing Merge Tags</h4> |
| 261 | 261 | <p>GravityView now offers better support for pricing Merge Tags to show details about orers. <a href="http://docs.gravityview.co/article/76-merge-tags">Read more about the Merge Tags</a>.</p> |
| 262 | 262 | </div> |
| 263 | 263 | |
| 264 | 264 | <div class="col col-2 last-feature"> |
| 265 | - <div class="media-container" style="margin-top: 2em; min-height:80px;"><img src="<?php echo plugins_url( 'assets/images/screenshots/developing-future.jpg', GRAVITYVIEW_FILE ); ?>" alt="Developing the Future"></div> |
|
| 265 | + <div class="media-container" style="margin-top: 2em; min-height:80px;"><img src="<?php echo plugins_url('assets/images/screenshots/developing-future.jpg', GRAVITYVIEW_FILE); ?>" alt="Developing the Future"></div> |
|
| 266 | 266 | <h4 class="higher">Laying the Groundwork</h4> |
| 267 | 267 | <p>We’re working on a great new View Builder to make it easier than ever to configure View layouts. This release includes lots of behind-the-scenes changes.</p> |
| 268 | 268 | </div> |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | |
| 479 | 479 | <?php $this->tabs(); ?> |
| 480 | 480 | |
| 481 | - <p class="about-description"><?php _e( 'GravityView is brought to you by:', 'gravityview' ); ?></p> |
|
| 481 | + <p class="about-description"><?php _e('GravityView is brought to you by:', 'gravityview'); ?></p> |
|
| 482 | 482 | |
| 483 | 483 | <div class="feature-section col two-col"> |
| 484 | 484 | |
@@ -486,14 +486,14 @@ discard block |
||
| 486 | 486 | <h2>Zack Katz</h2> |
| 487 | 487 | <h4 style="font-weight:0; margin-top:0">Project Lead & Developer</h4> |
| 488 | 488 | <p></p> |
| 489 | - <p><img style="float:left; margin: 0 15px 10px 0;" src="<?php echo plugins_url( 'assets/images/zack.jpg', GRAVITYVIEW_FILE ); ?>" width="94" height="94" />Zack has been developing integrations with Gravity Forms since 2009. He is the President of Katz Web Services and lives with his wife (and cat) in Denver, Colorado.</p> |
|
| 489 | + <p><img style="float:left; margin: 0 15px 10px 0;" src="<?php echo plugins_url('assets/images/zack.jpg', GRAVITYVIEW_FILE); ?>" width="94" height="94" />Zack has been developing integrations with Gravity Forms since 2009. He is the President of Katz Web Services and lives with his wife (and cat) in Denver, Colorado.</p> |
|
| 490 | 490 | <p><a href="https://katz.co">View Zack’s website</a></p> |
| 491 | 491 | </div> |
| 492 | 492 | |
| 493 | 493 | <div class="col last-feature"> |
| 494 | 494 | <h2>Luis Godinho</h2> |
| 495 | 495 | <h4 style="font-weight:0; margin-top:0">Developer & Support</h4> |
| 496 | - <p><img style="margin: 0 15px 10px 0;" class="alignleft avatar" src="<?php echo plugins_url( 'assets/images/luis.jpg', GRAVITYVIEW_FILE ); ?>" width="94" height="94" />Luis is a WordPress developer passionate about WordPress. He is a co-founder and partner of GOMO, a digital agency located in Lisbon, Portugal.</p> |
|
| 496 | + <p><img style="margin: 0 15px 10px 0;" class="alignleft avatar" src="<?php echo plugins_url('assets/images/luis.jpg', GRAVITYVIEW_FILE); ?>" width="94" height="94" />Luis is a WordPress developer passionate about WordPress. He is a co-founder and partner of GOMO, a digital agency located in Lisbon, Portugal.</p> |
|
| 497 | 497 | <p><a href="http://tinygod.pt">View Luis’s website</a></p> |
| 498 | 498 | </div> |
| 499 | 499 | |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | |
| 504 | 504 | <div class="feature-section"> |
| 505 | 505 | <div> |
| 506 | - <h2><?php esc_attr_e( 'Contributors', 'gravityview' ); ?></h2> |
|
| 506 | + <h2><?php esc_attr_e('Contributors', 'gravityview'); ?></h2> |
|
| 507 | 507 | |
| 508 | 508 | <ul class="wp-people-group"> |
| 509 | 509 | <li class="wp-person">Bengali translation by <a href="https://www.transifex.com/accounts/profile/tareqhi/">@tareqhi</a></li> |
@@ -524,8 +524,8 @@ discard block |
||
| 524 | 524 | <li class="wp-person">Code contributions by <a href="https://github.com/ryanduff">@ryanduff</a> and <a href="https://github.com/dmlinn">@dmlinn</a></li> |
| 525 | 525 | </ul> |
| 526 | 526 | |
| 527 | - <h4><?php esc_attr_e( 'Want to contribute?', 'gravityview' ); ?></h4> |
|
| 528 | - <p><?php echo sprintf( esc_attr__( 'If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview'), '<a href="https://github.com/katzwebservices/GravityView">', '</a>' ); ?></p> |
|
| 527 | + <h4><?php esc_attr_e('Want to contribute?', 'gravityview'); ?></h4> |
|
| 528 | + <p><?php echo sprintf(esc_attr__('If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview'), '<a href="https://github.com/katzwebservices/GravityView">', '</a>'); ?></p> |
|
| 529 | 529 | </div> |
| 530 | 530 | </div> |
| 531 | 531 | |
@@ -565,34 +565,34 @@ discard block |
||
| 565 | 565 | global $plugin_page; |
| 566 | 566 | |
| 567 | 567 | // Bail if we're just editing the plugin |
| 568 | - if( $plugin_page === 'plugin-editor.php' ) { return; } |
|
| 568 | + if ($plugin_page === 'plugin-editor.php') { return; } |
|
| 569 | 569 | |
| 570 | 570 | // Bail if no activation redirect |
| 571 | - if ( ! get_transient( '_gv_activation_redirect' ) ) { return; } |
|
| 571 | + if (!get_transient('_gv_activation_redirect')) { return; } |
|
| 572 | 572 | |
| 573 | 573 | // Delete the redirect transient |
| 574 | - delete_transient( '_gv_activation_redirect' ); |
|
| 574 | + delete_transient('_gv_activation_redirect'); |
|
| 575 | 575 | |
| 576 | - $upgrade = get_option( 'gv_version_upgraded_from' ); |
|
| 576 | + $upgrade = get_option('gv_version_upgraded_from'); |
|
| 577 | 577 | |
| 578 | 578 | // Don't do anything if they've already seen the new version info |
| 579 | - if( $upgrade === GravityView_Plugin::version ) { |
|
| 579 | + if ($upgrade === GravityView_Plugin::version) { |
|
| 580 | 580 | return; |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | // Add "Upgraded From" Option |
| 584 | - update_option( 'gv_version_upgraded_from', GravityView_Plugin::version ); |
|
| 584 | + update_option('gv_version_upgraded_from', GravityView_Plugin::version); |
|
| 585 | 585 | |
| 586 | 586 | // Bail if activating from network, or bulk |
| 587 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { return; } |
|
| 587 | + if (is_network_admin() || isset($_GET['activate-multi'])) { return; } |
|
| 588 | 588 | |
| 589 | 589 | // First time install |
| 590 | - if( ! $upgrade ) { |
|
| 591 | - wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-getting-started' ) ); exit; |
|
| 590 | + if (!$upgrade) { |
|
| 591 | + wp_safe_redirect(admin_url('edit.php?post_type=gravityview&page=gv-getting-started')); exit; |
|
| 592 | 592 | } |
| 593 | 593 | // Update |
| 594 | 594 | else { |
| 595 | - wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-changelog' ) ); exit; |
|
| 595 | + wp_safe_redirect(admin_url('edit.php?post_type=gravityview&page=gv-changelog')); exit; |
|
| 596 | 596 | } |
| 597 | 597 | } |
| 598 | 598 | } |
@@ -1,15 +1,15 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Welcome Page Class |
|
| 4 | - * |
|
| 5 | - * @package GravityView |
|
| 6 | - * @author Zack Katz <[email protected]> |
|
| 7 | - * @license ToBeDefined |
|
| 8 | - * @link http://www.katzwebservices.com |
|
| 9 | - * @copyright Copyright 2014, Katz Web Services, Inc. |
|
| 10 | - * |
|
| 11 | - * @since 1.0.0 |
|
| 12 | - */ |
|
| 3 | + * Welcome Page Class |
|
| 4 | + * |
|
| 5 | + * @package GravityView |
|
| 6 | + * @author Zack Katz <[email protected]> |
|
| 7 | + * @license ToBeDefined |
|
| 8 | + * @link http://www.katzwebservices.com |
|
| 9 | + * @copyright Copyright 2014, Katz Web Services, Inc. |
|
| 10 | + * |
|
| 11 | + * @since 1.0.0 |
|
| 12 | + */ |
|
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) exit; |
@@ -158,6 +158,7 @@ |
||
| 158 | 158 | /** |
| 159 | 159 | * important! Override this class if needed |
| 160 | 160 | * outputs the field setting html |
| 161 | + * @param string $override_input |
|
| 161 | 162 | */ |
| 162 | 163 | function render_setting( $override_input = NULL ) { |
| 163 | 164 | |
@@ -10,159 +10,159 @@ discard block |
||
| 10 | 10 | * |
| 11 | 11 | * @var string |
| 12 | 12 | */ |
| 13 | - protected $name; |
|
| 13 | + protected $name; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Field settings |
| 17 | 17 | * |
| 18 | 18 | * @var array |
| 19 | 19 | */ |
| 20 | - protected $field; |
|
| 20 | + protected $field; |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * Field current value |
| 24 | 24 | * |
| 25 | 25 | * @var mixed |
| 26 | 26 | */ |
| 27 | - protected $value; |
|
| 28 | - |
|
| 29 | - function __construct( $name = '', $field = array(), $curr_value = NULL ) { |
|
| 30 | - |
|
| 31 | - $this->name = $name; |
|
| 32 | - |
|
| 33 | - $defaults = self::get_field_defaults(); |
|
| 34 | - |
|
| 35 | - // Backward compatibility |
|
| 36 | - if( !empty( $field['choices'] ) ) { |
|
| 37 | - $field['options'] = $field['choices']; |
|
| 38 | - unset( $field['choices'] ); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - $this->field = wp_parse_args( $field, $defaults ); |
|
| 42 | - |
|
| 43 | - $this->value = is_null( $curr_value ) ? $this->field['value'] : $curr_value; |
|
| 44 | - |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Returns the default details for a field option |
|
| 49 | - * |
|
| 50 | - * - default // default option value, in case nothing is defined (@deprecated) |
|
| 51 | - * - desc // option description |
|
| 52 | - * - value // the option default value |
|
| 53 | - * - label // the option label |
|
| 54 | - * - left_label // In case of checkboxes, left label will appear on the left of the checkbox |
|
| 55 | - * - id // the field id |
|
| 56 | - * - type // the option type ( text, checkbox, select, ... ) |
|
| 57 | - * - options // when type is select, define the select options ('choices' is @deprecated) |
|
| 58 | - * - merge_tags // if the option supports merge tags feature |
|
| 59 | - * - class // (new) define extra classes for the field |
|
| 60 | - * - tooltip // |
|
| 61 | - * |
|
| 62 | - * @return array |
|
| 63 | - */ |
|
| 64 | - public static function get_field_defaults() { |
|
| 65 | - return array( |
|
| 66 | - 'desc' => '', |
|
| 67 | - 'value' => NULL, |
|
| 68 | - 'label' => '', |
|
| 69 | - 'left_label' => NULL, |
|
| 70 | - 'id' => NULL, |
|
| 71 | - 'type' => 'text', |
|
| 72 | - 'options' => NULL, |
|
| 73 | - 'merge_tags' => true, |
|
| 74 | - 'class' => '', |
|
| 75 | - 'tooltip' => NULL |
|
| 76 | - ); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - function get_tooltip() { |
|
| 81 | - if( !function_exists('gform_tooltip') ) { |
|
| 82 | - return NULL; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - return !empty( $this->field['tooltip'] ) ? ' '.gform_tooltip( $this->field['tooltip'] , false, true ) : NULL; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Build input id based on the name |
|
| 90 | - * @return string |
|
| 91 | - */ |
|
| 92 | - function get_field_id() { |
|
| 93 | - if( isset( $this->field['id'] ) ) { |
|
| 94 | - return esc_attr( $this->field['id'] ); |
|
| 95 | - } |
|
| 96 | - return esc_attr( sanitize_html_class( $this->name ) ); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Retrieve field label |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function get_field_label() { |
|
| 104 | - return esc_html( trim( $this->field['label'] ) ); |
|
| 105 | - } |
|
| 27 | + protected $value; |
|
| 28 | + |
|
| 29 | + function __construct( $name = '', $field = array(), $curr_value = NULL ) { |
|
| 30 | + |
|
| 31 | + $this->name = $name; |
|
| 32 | + |
|
| 33 | + $defaults = self::get_field_defaults(); |
|
| 34 | + |
|
| 35 | + // Backward compatibility |
|
| 36 | + if( !empty( $field['choices'] ) ) { |
|
| 37 | + $field['options'] = $field['choices']; |
|
| 38 | + unset( $field['choices'] ); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + $this->field = wp_parse_args( $field, $defaults ); |
|
| 42 | + |
|
| 43 | + $this->value = is_null( $curr_value ) ? $this->field['value'] : $curr_value; |
|
| 44 | + |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Returns the default details for a field option |
|
| 49 | + * |
|
| 50 | + * - default // default option value, in case nothing is defined (@deprecated) |
|
| 51 | + * - desc // option description |
|
| 52 | + * - value // the option default value |
|
| 53 | + * - label // the option label |
|
| 54 | + * - left_label // In case of checkboxes, left label will appear on the left of the checkbox |
|
| 55 | + * - id // the field id |
|
| 56 | + * - type // the option type ( text, checkbox, select, ... ) |
|
| 57 | + * - options // when type is select, define the select options ('choices' is @deprecated) |
|
| 58 | + * - merge_tags // if the option supports merge tags feature |
|
| 59 | + * - class // (new) define extra classes for the field |
|
| 60 | + * - tooltip // |
|
| 61 | + * |
|
| 62 | + * @return array |
|
| 63 | + */ |
|
| 64 | + public static function get_field_defaults() { |
|
| 65 | + return array( |
|
| 66 | + 'desc' => '', |
|
| 67 | + 'value' => NULL, |
|
| 68 | + 'label' => '', |
|
| 69 | + 'left_label' => NULL, |
|
| 70 | + 'id' => NULL, |
|
| 71 | + 'type' => 'text', |
|
| 72 | + 'options' => NULL, |
|
| 73 | + 'merge_tags' => true, |
|
| 74 | + 'class' => '', |
|
| 75 | + 'tooltip' => NULL |
|
| 76 | + ); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + function get_tooltip() { |
|
| 81 | + if( !function_exists('gform_tooltip') ) { |
|
| 82 | + return NULL; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + return !empty( $this->field['tooltip'] ) ? ' '.gform_tooltip( $this->field['tooltip'] , false, true ) : NULL; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Build input id based on the name |
|
| 90 | + * @return string |
|
| 91 | + */ |
|
| 92 | + function get_field_id() { |
|
| 93 | + if( isset( $this->field['id'] ) ) { |
|
| 94 | + return esc_attr( $this->field['id'] ); |
|
| 95 | + } |
|
| 96 | + return esc_attr( sanitize_html_class( $this->name ) ); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Retrieve field label |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function get_field_label() { |
|
| 104 | + return esc_html( trim( $this->field['label'] ) ); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * Retrieve field left label |
| 109 | - * |
|
| 110 | - * @since 1.7 |
|
| 111 | - * |
|
| 109 | + * |
|
| 110 | + * @since 1.7 |
|
| 111 | + * |
|
| 112 | 112 | * @return string |
| 113 | 113 | */ |
| 114 | 114 | function get_field_left_label() { |
| 115 | 115 | return ! empty( $this->field['left_label'] ) ? esc_html( trim( $this->field['left_label'] ) ) : NULL; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Retrieve field label class |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 122 | - function get_label_class() { |
|
| 123 | - return 'gv-label-'. sanitize_html_class( $this->field['type'] ); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Retrieve field description |
|
| 129 | - * @return string |
|
| 130 | - */ |
|
| 131 | - function get_field_desc() { |
|
| 132 | - return !empty( $this->field['desc'] ) ? '<span class="howto">'. $this->field['desc'] .'</span>' : ''; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Verify if field should have merge tags |
|
| 138 | - * @return boolean |
|
| 139 | - */ |
|
| 140 | - function show_merge_tags() { |
|
| 141 | - // Show the merge tags if the field is a list view |
|
| 142 | - $is_list = preg_match( '/_list-/ism', $this->name ); |
|
| 143 | - // Or is a single entry view |
|
| 144 | - $is_single = preg_match( '/single_/ism', $this->name ); |
|
| 145 | - |
|
| 146 | - return ( $is_single || $is_list ); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * important! Override this class |
|
| 153 | - * outputs the field option html |
|
| 154 | - */ |
|
| 155 | - function render_option() { |
|
| 156 | - // to replace on each field |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * important! Override this class if needed |
|
| 161 | - * outputs the field setting html |
|
| 162 | - */ |
|
| 163 | - function render_setting( $override_input = NULL ) { |
|
| 164 | - |
|
| 165 | - if( !empty( $this->field['full_width'] ) ) { ?> |
|
| 118 | + /** |
|
| 119 | + * Retrieve field label class |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | + function get_label_class() { |
|
| 123 | + return 'gv-label-'. sanitize_html_class( $this->field['type'] ); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Retrieve field description |
|
| 129 | + * @return string |
|
| 130 | + */ |
|
| 131 | + function get_field_desc() { |
|
| 132 | + return !empty( $this->field['desc'] ) ? '<span class="howto">'. $this->field['desc'] .'</span>' : ''; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Verify if field should have merge tags |
|
| 138 | + * @return boolean |
|
| 139 | + */ |
|
| 140 | + function show_merge_tags() { |
|
| 141 | + // Show the merge tags if the field is a list view |
|
| 142 | + $is_list = preg_match( '/_list-/ism', $this->name ); |
|
| 143 | + // Or is a single entry view |
|
| 144 | + $is_single = preg_match( '/single_/ism', $this->name ); |
|
| 145 | + |
|
| 146 | + return ( $is_single || $is_list ); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * important! Override this class |
|
| 153 | + * outputs the field option html |
|
| 154 | + */ |
|
| 155 | + function render_option() { |
|
| 156 | + // to replace on each field |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * important! Override this class if needed |
|
| 161 | + * outputs the field setting html |
|
| 162 | + */ |
|
| 163 | + function render_setting( $override_input = NULL ) { |
|
| 164 | + |
|
| 165 | + if( !empty( $this->field['full_width'] ) ) { ?> |
|
| 166 | 166 | <th scope="row" colspan="2"> |
| 167 | 167 | <div> |
| 168 | 168 | <label for="<?php echo $this->get_field_id(); ?>"> |
@@ -182,14 +182,14 @@ discard block |
||
| 182 | 182 | </td> |
| 183 | 183 | <?php } |
| 184 | 184 | |
| 185 | - } |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - /** |
|
| 188 | - * important! Override this class |
|
| 189 | - * outputs the input html part |
|
| 190 | - */ |
|
| 191 | - function render_input( $override_input ) { |
|
| 192 | - echo ''; |
|
| 193 | - } |
|
| 187 | + /** |
|
| 188 | + * important! Override this class |
|
| 189 | + * outputs the input html part |
|
| 190 | + */ |
|
| 191 | + function render_input( $override_input ) { |
|
| 192 | + echo ''; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | 195 | } |
@@ -26,21 +26,21 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | protected $value; |
| 28 | 28 | |
| 29 | - function __construct( $name = '', $field = array(), $curr_value = NULL ) { |
|
| 29 | + function __construct($name = '', $field = array(), $curr_value = NULL) { |
|
| 30 | 30 | |
| 31 | 31 | $this->name = $name; |
| 32 | 32 | |
| 33 | 33 | $defaults = self::get_field_defaults(); |
| 34 | 34 | |
| 35 | 35 | // Backward compatibility |
| 36 | - if( !empty( $field['choices'] ) ) { |
|
| 36 | + if (!empty($field['choices'])) { |
|
| 37 | 37 | $field['options'] = $field['choices']; |
| 38 | - unset( $field['choices'] ); |
|
| 38 | + unset($field['choices']); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $this->field = wp_parse_args( $field, $defaults ); |
|
| 41 | + $this->field = wp_parse_args($field, $defaults); |
|
| 42 | 42 | |
| 43 | - $this->value = is_null( $curr_value ) ? $this->field['value'] : $curr_value; |
|
| 43 | + $this->value = is_null($curr_value) ? $this->field['value'] : $curr_value; |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | function get_tooltip() { |
| 81 | - if( !function_exists('gform_tooltip') ) { |
|
| 81 | + if (!function_exists('gform_tooltip')) { |
|
| 82 | 82 | return NULL; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - return !empty( $this->field['tooltip'] ) ? ' '.gform_tooltip( $this->field['tooltip'] , false, true ) : NULL; |
|
| 85 | + return !empty($this->field['tooltip']) ? ' '.gform_tooltip($this->field['tooltip'], false, true) : NULL; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | * @return string |
| 91 | 91 | */ |
| 92 | 92 | function get_field_id() { |
| 93 | - if( isset( $this->field['id'] ) ) { |
|
| 94 | - return esc_attr( $this->field['id'] ); |
|
| 93 | + if (isset($this->field['id'])) { |
|
| 94 | + return esc_attr($this->field['id']); |
|
| 95 | 95 | } |
| 96 | - return esc_attr( sanitize_html_class( $this->name ) ); |
|
| 96 | + return esc_attr(sanitize_html_class($this->name)); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return string |
| 102 | 102 | */ |
| 103 | 103 | function get_field_label() { |
| 104 | - return esc_html( trim( $this->field['label'] ) ); |
|
| 104 | + return esc_html(trim($this->field['label'])); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @return string |
| 113 | 113 | */ |
| 114 | 114 | function get_field_left_label() { |
| 115 | - return ! empty( $this->field['left_label'] ) ? esc_html( trim( $this->field['left_label'] ) ) : NULL; |
|
| 115 | + return !empty($this->field['left_label']) ? esc_html(trim($this->field['left_label'])) : NULL; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @return string |
| 121 | 121 | */ |
| 122 | 122 | function get_label_class() { |
| 123 | - return 'gv-label-'. sanitize_html_class( $this->field['type'] ); |
|
| 123 | + return 'gv-label-'.sanitize_html_class($this->field['type']); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return string |
| 130 | 130 | */ |
| 131 | 131 | function get_field_desc() { |
| 132 | - return !empty( $this->field['desc'] ) ? '<span class="howto">'. $this->field['desc'] .'</span>' : ''; |
|
| 132 | + return !empty($this->field['desc']) ? '<span class="howto">'.$this->field['desc'].'</span>' : ''; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | function show_merge_tags() { |
| 141 | 141 | // Show the merge tags if the field is a list view |
| 142 | - $is_list = preg_match( '/_list-/ism', $this->name ); |
|
| 142 | + $is_list = preg_match('/_list-/ism', $this->name); |
|
| 143 | 143 | // Or is a single entry view |
| 144 | - $is_single = preg_match( '/single_/ism', $this->name ); |
|
| 144 | + $is_single = preg_match('/single_/ism', $this->name); |
|
| 145 | 145 | |
| 146 | - return ( $is_single || $is_list ); |
|
| 146 | + return ($is_single || $is_list); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
@@ -160,25 +160,25 @@ discard block |
||
| 160 | 160 | * important! Override this class if needed |
| 161 | 161 | * outputs the field setting html |
| 162 | 162 | */ |
| 163 | - function render_setting( $override_input = NULL ) { |
|
| 163 | + function render_setting($override_input = NULL) { |
|
| 164 | 164 | |
| 165 | - if( !empty( $this->field['full_width'] ) ) { ?> |
|
| 165 | + if (!empty($this->field['full_width'])) { ?> |
|
| 166 | 166 | <th scope="row" colspan="2"> |
| 167 | 167 | <div> |
| 168 | 168 | <label for="<?php echo $this->get_field_id(); ?>"> |
| 169 | - <?php echo $this->get_field_label() . $this->get_tooltip(); ?> |
|
| 169 | + <?php echo $this->get_field_label().$this->get_tooltip(); ?> |
|
| 170 | 170 | </label> |
| 171 | 171 | </div> |
| 172 | - <?php $this->render_input( $override_input ); ?> |
|
| 172 | + <?php $this->render_input($override_input); ?> |
|
| 173 | 173 | </th> |
| 174 | 174 | <?php } else { ?> |
| 175 | 175 | <th scope="row"> |
| 176 | 176 | <label for="<?php echo $this->get_field_id(); ?>"> |
| 177 | - <?php echo $this->get_field_label() . $this->get_tooltip(); ?> |
|
| 177 | + <?php echo $this->get_field_label().$this->get_tooltip(); ?> |
|
| 178 | 178 | </label> |
| 179 | 179 | </th> |
| 180 | 180 | <td> |
| 181 | - <?php $this->render_input( $override_input ); ?> |
|
| 181 | + <?php $this->render_input($override_input); ?> |
|
| 182 | 182 | </td> |
| 183 | 183 | <?php } |
| 184 | 184 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * important! Override this class |
| 189 | 189 | * outputs the input html part |
| 190 | 190 | */ |
| 191 | - function render_input( $override_input ) { |
|
| 191 | + function render_input($override_input) { |
|
| 192 | 192 | echo ''; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -214,7 +214,6 @@ discard block |
||
| 214 | 214 | * |
| 215 | 215 | * @access public |
| 216 | 216 | * @param array $entry |
| 217 | - * @param integer $field |
|
| 218 | 217 | * @return null|string |
| 219 | 218 | */ |
| 220 | 219 | public static function field_value( $entry, $field_settings, $format = 'html' ) { |
@@ -967,7 +966,7 @@ discard block |
||
| 967 | 966 | * Get the current View ID being rendered |
| 968 | 967 | * |
| 969 | 968 | * @global GravityView_View $gravityview_view |
| 970 | - * @return string View context "directory" or "single" |
|
| 969 | + * @return integer View context "directory" or "single" |
|
| 971 | 970 | */ |
| 972 | 971 | function gravityview_get_view_id() { |
| 973 | 972 | return GravityView_View::getInstance()->getViewId(); |
@@ -146,20 +146,20 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | if( !empty( $field['custom_class'] ) ) { |
| 148 | 148 | |
| 149 | - $custom_class = $field['custom_class']; |
|
| 149 | + $custom_class = $field['custom_class']; |
|
| 150 | 150 | |
| 151 | - if( !empty( $entry ) ) { |
|
| 151 | + if( !empty( $entry ) ) { |
|
| 152 | 152 | |
| 153 | - // We want the merge tag to be formatted as a class. The merge tag may be |
|
| 154 | - // replaced by a multiple-word value that should be output as a single class. |
|
| 155 | - // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
|
| 156 | - add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 153 | + // We want the merge tag to be formatted as a class. The merge tag may be |
|
| 154 | + // replaced by a multiple-word value that should be output as a single class. |
|
| 155 | + // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
|
| 156 | + add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 157 | 157 | |
| 158 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
| 158 | + $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
| 159 | 159 | |
| 160 | - // And then we want life to return to normal |
|
| 161 | - remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 162 | - } |
|
| 160 | + // And then we want life to return to normal |
|
| 161 | + remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | 164 | // And now we want the spaces to be handled nicely. |
| 165 | 165 | $classes[] = gravityview_sanitize_html_class( $custom_class ); |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | 'format' => $format, |
| 293 | 293 | 'entry' => $entry, |
| 294 | 294 | 'field_type' => $field_type, /** {@since 1.6} */ |
| 295 | - 'field_path' => $field_path, /** {@since 1.16} */ |
|
| 295 | + 'field_path' => $field_path, /** {@since 1.16} */ |
|
| 296 | 296 | )); |
| 297 | 297 | |
| 298 | 298 | if( ! empty( $field_path ) ) { |
@@ -603,29 +603,29 @@ discard block |
||
| 603 | 603 | return sanitize_title( $slug ); |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - /** |
|
| 607 | - * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta |
|
| 608 | - * |
|
| 609 | - * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
|
| 610 | - * |
|
| 611 | - * @param $entry array Gravity Forms entry object |
|
| 612 | - * @param $form array Gravity Forms form object |
|
| 613 | - */ |
|
| 614 | - public static function entry_create_custom_slug( $entry, $form ) { |
|
| 615 | - /** |
|
| 616 | - * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta |
|
| 617 | - * @param boolean $custom Should we process the custom entry slug? |
|
| 618 | - */ |
|
| 619 | - $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
| 620 | - if( $custom ) { |
|
| 621 | - // create the gravityview_unique_id and save it |
|
| 606 | + /** |
|
| 607 | + * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta |
|
| 608 | + * |
|
| 609 | + * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
|
| 610 | + * |
|
| 611 | + * @param $entry array Gravity Forms entry object |
|
| 612 | + * @param $form array Gravity Forms form object |
|
| 613 | + */ |
|
| 614 | + public static function entry_create_custom_slug( $entry, $form ) { |
|
| 615 | + /** |
|
| 616 | + * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta |
|
| 617 | + * @param boolean $custom Should we process the custom entry slug? |
|
| 618 | + */ |
|
| 619 | + $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
| 620 | + if( $custom ) { |
|
| 621 | + // create the gravityview_unique_id and save it |
|
| 622 | 622 | |
| 623 | - // Get the entry hash |
|
| 624 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
| 625 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
| 623 | + // Get the entry hash |
|
| 624 | + $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
| 625 | + gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
| 626 | 626 | |
| 627 | - } |
|
| 628 | - } |
|
| 627 | + } |
|
| 628 | + } |
|
| 629 | 629 | |
| 630 | 630 | |
| 631 | 631 | |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | |
| 890 | 890 | // If there was an error, continue to the next term. |
| 891 | 891 | if ( is_wp_error( $term_link ) ) { |
| 892 | - continue; |
|
| 892 | + continue; |
|
| 893 | 893 | } |
| 894 | 894 | |
| 895 | 895 | $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
@@ -23,36 +23,36 @@ discard block |
||
| 23 | 23 | * @param boolean $force_show_label Whether to always show the label, regardless of field settings |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | - public static function field_label( $field, $entry = array(), $force_show_label = false ) { |
|
| 26 | + public static function field_label($field, $entry = array(), $force_show_label = false) { |
|
| 27 | 27 | $gravityview_view = GravityView_View::getInstance(); |
| 28 | 28 | |
| 29 | 29 | $form = $gravityview_view->getForm(); |
| 30 | 30 | |
| 31 | 31 | $label = ''; |
| 32 | 32 | |
| 33 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
| 33 | + if (!empty($field['show_label']) || $force_show_label) { |
|
| 34 | 34 | |
| 35 | 35 | $label = $field['label']; |
| 36 | 36 | |
| 37 | 37 | // Support Gravity Forms 1.9+ |
| 38 | - if( class_exists( 'GF_Field' ) ) { |
|
| 38 | + if (class_exists('GF_Field')) { |
|
| 39 | 39 | |
| 40 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
| 40 | + $field_object = RGFormsModel::get_field($form, $field['id']); |
|
| 41 | 41 | |
| 42 | - if( $field_object ) { |
|
| 42 | + if ($field_object) { |
|
| 43 | 43 | |
| 44 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
| 44 | + $input = GFFormsModel::get_input($field_object, $field['id']); |
|
| 45 | 45 | |
| 46 | 46 | // This is a complex field, with labels on a per-input basis |
| 47 | - if( $input ) { |
|
| 47 | + if ($input) { |
|
| 48 | 48 | |
| 49 | 49 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
| 50 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
| 50 | + $label = !empty($input['customLabel']) ? $input['customLabel'] : $input['label']; |
|
| 51 | 51 | |
| 52 | 52 | } else { |
| 53 | 53 | |
| 54 | 54 | // This is a field with one label |
| 55 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
| 55 | + $label = $field_object->get_field_label(true, $field['label']); |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
| 64 | - if ( !empty( $field['custom_label'] ) ) { |
|
| 64 | + if (!empty($field['custom_label'])) { |
|
| 65 | 65 | |
| 66 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
| 66 | + $label = self::replace_variables($field['custom_label'], $form, $entry); |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param[in,out] string $appended_content Content you can add after a label. Empty by default. |
| 73 | 73 | * @param[in] array $field GravityView field array |
| 74 | 74 | */ |
| 75 | - $label .= apply_filters( 'gravityview_render_after_label', '', $field ); |
|
| 75 | + $label .= apply_filters('gravityview_render_after_label', '', $field); |
|
| 76 | 76 | |
| 77 | 77 | } // End $field['show_label'] |
| 78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param[in] array $form Gravity Forms form array |
| 85 | 85 | * @param[in] array $entry Gravity Forms entry array |
| 86 | 86 | */ |
| 87 | - $label = apply_filters( 'gravityview/template/field_label', $label, $field, $form, $entry ); |
|
| 87 | + $label = apply_filters('gravityview/template/field_label', $label, $field, $form, $entry); |
|
| 88 | 88 | |
| 89 | 89 | return $label; |
| 90 | 90 | } |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | * @param array $entry GF Entry array |
| 100 | 100 | * @return string Text with variables maybe replaced |
| 101 | 101 | */ |
| 102 | - public static function replace_variables($text, $form, $entry ) { |
|
| 103 | - return GravityView_Merge_Tags::replace_variables( $text, $form, $entry ); |
|
| 102 | + public static function replace_variables($text, $form, $entry) { |
|
| 103 | + return GravityView_Merge_Tags::replace_variables($text, $form, $entry); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -113,19 +113,19 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return string|null If not empty, string in $format format. Otherwise, null. |
| 115 | 115 | */ |
| 116 | - public static function field_width( $field, $format = '%d%%' ) { |
|
| 116 | + public static function field_width($field, $format = '%d%%') { |
|
| 117 | 117 | |
| 118 | 118 | $width = NULL; |
| 119 | 119 | |
| 120 | - if( !empty( $field['width'] ) ) { |
|
| 121 | - $width = absint( $field['width'] ); |
|
| 120 | + if (!empty($field['width'])) { |
|
| 121 | + $width = absint($field['width']); |
|
| 122 | 122 | |
| 123 | 123 | // If using percentages, limit to 100% |
| 124 | - if( '%d%%' === $format && $width > 100 ) { |
|
| 124 | + if ('%d%%' === $format && $width > 100) { |
|
| 125 | 125 | $width = 100; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $width = sprintf( $format, $width ); |
|
| 128 | + $width = sprintf($format, $width); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | return $width; |
@@ -139,38 +139,38 @@ discard block |
||
| 139 | 139 | * @param mixed $field |
| 140 | 140 | * @return string |
| 141 | 141 | */ |
| 142 | - public static function field_class( $field, $form = NULL, $entry = NULL ) { |
|
| 142 | + public static function field_class($field, $form = NULL, $entry = NULL) { |
|
| 143 | 143 | $gravityview_view = GravityView_View::getInstance(); |
| 144 | 144 | |
| 145 | 145 | $classes = array(); |
| 146 | 146 | |
| 147 | - if( !empty( $field['custom_class'] ) ) { |
|
| 147 | + if (!empty($field['custom_class'])) { |
|
| 148 | 148 | |
| 149 | 149 | $custom_class = $field['custom_class']; |
| 150 | 150 | |
| 151 | - if( !empty( $entry ) ) { |
|
| 151 | + if (!empty($entry)) { |
|
| 152 | 152 | |
| 153 | 153 | // We want the merge tag to be formatted as a class. The merge tag may be |
| 154 | 154 | // replaced by a multiple-word value that should be output as a single class. |
| 155 | 155 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
| 156 | 156 | add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
| 157 | 157 | |
| 158 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
| 158 | + $custom_class = self::replace_variables($custom_class, $form, $entry); |
|
| 159 | 159 | |
| 160 | 160 | // And then we want life to return to normal |
| 161 | 161 | remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // And now we want the spaces to be handled nicely. |
| 165 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
| 165 | + $classes[] = gravityview_sanitize_html_class($custom_class); |
|
| 166 | 166 | |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if(!empty($field['id'])) { |
|
| 170 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
| 169 | + if (!empty($field['id'])) { |
|
| 170 | + if (!empty($form) && !empty($form['id'])) { |
|
| 171 | 171 | $form_id = '-'.$form['id']; |
| 172 | 172 | } else { |
| 173 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
| 173 | + $form_id = $gravityview_view->getFormId() ? '-'.$gravityview_view->getFormId() : ''; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
@@ -191,21 +191,21 @@ discard block |
||
| 191 | 191 | * @param array $entry Gravity Forms entry array |
| 192 | 192 | * @return string Sanitized unique HTML `id` attribute for the field |
| 193 | 193 | */ |
| 194 | - public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
|
| 194 | + public static function field_html_attr_id($field, $form = array(), $entry = array()) { |
|
| 195 | 195 | $gravityview_view = GravityView_View::getInstance(); |
| 196 | 196 | $id = $field['id']; |
| 197 | 197 | |
| 198 | - if ( ! empty( $id ) ) { |
|
| 199 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
| 200 | - $form_id = '-' . $form['id']; |
|
| 198 | + if (!empty($id)) { |
|
| 199 | + if (!empty($form) && !empty($form['id'])) { |
|
| 200 | + $form_id = '-'.$form['id']; |
|
| 201 | 201 | } else { |
| 202 | - $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
| 202 | + $form_id = $gravityview_view->getFormId() ? '-'.$gravityview_view->getFormId() : ''; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
| 205 | + $id = 'gv-field'.$form_id.'-'.$field['id']; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - return esc_attr( $id ); |
|
| 208 | + return esc_attr($id); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -217,15 +217,15 @@ discard block |
||
| 217 | 217 | * @param integer $field |
| 218 | 218 | * @return null|string |
| 219 | 219 | */ |
| 220 | - public static function field_value( $entry, $field_settings, $format = 'html' ) { |
|
| 220 | + public static function field_value($entry, $field_settings, $format = 'html') { |
|
| 221 | 221 | |
| 222 | - if( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
| 222 | + if (empty($entry['form_id']) || empty($field_settings['id'])) { |
|
| 223 | 223 | return NULL; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | $gravityview_view = GravityView_View::getInstance(); |
| 227 | 227 | |
| 228 | - if( class_exists( 'GFCache' ) ) { |
|
| 228 | + if (class_exists('GFCache')) { |
|
| 229 | 229 | /** |
| 230 | 230 | * Gravity Forms' GFCache function was thrashing the database, causing double the amount of time for the field_value() method to run. |
| 231 | 231 | * |
@@ -240,18 +240,18 @@ discard block |
||
| 240 | 240 | * @param boolean false Tell Gravity Forms not to store this as a transient |
| 241 | 241 | * @param int 0 Time to store the value. 0 is maximum amount of time possible. |
| 242 | 242 | */ |
| 243 | - GFCache::set( "GFFormsModel::get_lead_field_value_" . $entry["id"] . "_" . $field_settings["id"], false, false, 0 ); |
|
| 243 | + GFCache::set("GFFormsModel::get_lead_field_value_".$entry["id"]."_".$field_settings["id"], false, false, 0); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $field_id = $field_settings['id']; |
| 247 | 247 | |
| 248 | 248 | $form = $gravityview_view->getForm(); |
| 249 | 249 | |
| 250 | - $field = gravityview_get_field( $form, $field_id ); |
|
| 250 | + $field = gravityview_get_field($form, $field_id); |
|
| 251 | 251 | |
| 252 | 252 | $field_type = RGFormsModel::get_input_type($field); |
| 253 | 253 | |
| 254 | - if( $field_type ) { |
|
| 254 | + if ($field_type) { |
|
| 255 | 255 | $field_type = $field['type']; |
| 256 | 256 | $value = RGFormsModel::get_lead_field_value($entry, $field); |
| 257 | 257 | } else { |
@@ -266,15 +266,15 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | $display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format); |
| 268 | 268 | |
| 269 | - if( $errors = ob_get_clean() ) { |
|
| 270 | - do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors ); |
|
| 269 | + if ($errors = ob_get_clean()) { |
|
| 270 | + do_action('gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form); |
| 274 | 274 | |
| 275 | 275 | // prevent the use of merge_tags for non-admin fields |
| 276 | - if( !empty( $field['adminOnly'] ) ) { |
|
| 277 | - $display_value = self::replace_variables( $display_value, $form, $entry ); |
|
| 276 | + if (!empty($field['adminOnly'])) { |
|
| 277 | + $display_value = self::replace_variables($display_value, $form, $entry); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // Check whether the field exists in /includes/fields/{$field_type}.php |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $field_path = $gravityview_view->locate_template("fields/{$field_type}.php"); |
| 283 | 283 | |
| 284 | 284 | // Set the field data to be available in the templates |
| 285 | - $gravityview_view->setCurrentField( array( |
|
| 285 | + $gravityview_view->setCurrentField(array( |
|
| 286 | 286 | 'form' => $form, |
| 287 | 287 | 'field_id' => $field_id, |
| 288 | 288 | 'field' => $field, |
@@ -295,13 +295,13 @@ discard block |
||
| 295 | 295 | 'field_path' => $field_path, /** {@since 1.16} */ |
| 296 | 296 | )); |
| 297 | 297 | |
| 298 | - if( ! empty( $field_path ) ) { |
|
| 298 | + if (!empty($field_path)) { |
|
| 299 | 299 | |
| 300 | - do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path ) ); |
|
| 300 | + do_action('gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path)); |
|
| 301 | 301 | |
| 302 | 302 | ob_start(); |
| 303 | 303 | |
| 304 | - load_template( $field_path, false ); |
|
| 304 | + load_template($field_path, false); |
|
| 305 | 305 | |
| 306 | 306 | $output = ob_get_clean(); |
| 307 | 307 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * @param array $field_settings Settings for the particular GV field |
| 323 | 323 | * @param array $field Field array, as fetched from GravityView_View::getCurrentField() |
| 324 | 324 | */ |
| 325 | - $output = apply_filters( 'gravityview_field_entry_value_' . $field_type . '_pre_link', $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
| 325 | + $output = apply_filters('gravityview_field_entry_value_'.$field_type.'_pre_link', $output, $entry, $field_settings, $gravityview_view->getCurrentField()); |
|
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | 328 | * Link to the single entry by wrapping the output in an anchor tag |
@@ -330,11 +330,11 @@ discard block |
||
| 330 | 330 | * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example. |
| 331 | 331 | * |
| 332 | 332 | */ |
| 333 | - if( !empty( $field_settings['show_as_link'] ) && ! gv_empty( $output, false, false ) ) { |
|
| 333 | + if (!empty($field_settings['show_as_link']) && !gv_empty($output, false, false)) { |
|
| 334 | 334 | |
| 335 | - $link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' ); |
|
| 335 | + $link_atts = empty($field_settings['new_window']) ? array() : array('target' => '_blank'); |
|
| 336 | 336 | |
| 337 | - $output = self::entry_link_html( $entry, $output, $link_atts, $field_settings ); |
|
| 337 | + $output = self::entry_link_html($entry, $output, $link_atts, $field_settings); |
|
| 338 | 338 | |
| 339 | 339 | } |
| 340 | 340 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * @param array $field_settings Settings for the particular GV field |
| 347 | 347 | * @param array $field Current field being displayed |
| 348 | 348 | */ |
| 349 | - $output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
| 349 | + $output = apply_filters('gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField()); |
|
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * @filter `gravityview_field_entry_value` Modify the field value output for all field types |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | * @param array $field_settings Settings for the particular GV field |
| 356 | 356 | * @param array $field_data {@since 1.6} |
| 357 | 357 | */ |
| 358 | - $output = apply_filters( 'gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
| 358 | + $output = apply_filters('gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField()); |
|
| 359 | 359 | |
| 360 | 360 | return $output; |
| 361 | 361 | } |
@@ -369,18 +369,18 @@ discard block |
||
| 369 | 369 | * @param array $entry Gravity Forms entry array |
| 370 | 370 | * @param array $field_settings Array of field settings. Optional, but passed to the `gravityview_field_entry_link` filter |
| 371 | 371 | */ |
| 372 | - public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) { |
|
| 372 | + public static function entry_link_html($entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array()) { |
|
| 373 | 373 | |
| 374 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
| 374 | + if (empty($entry) || !is_array($entry) || !isset($entry['id'])) { |
|
| 375 | 375 | |
| 376 | - do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry ); |
|
| 376 | + do_action('gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry); |
|
| 377 | 377 | |
| 378 | 378 | return NULL; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - $href = self::entry_link( $entry ); |
|
| 381 | + $href = self::entry_link($entry); |
|
| 382 | 382 | |
| 383 | - $link = gravityview_get_link( $href, $anchor_text, $passed_tag_atts ); |
|
| 383 | + $link = gravityview_get_link($href, $anchor_text, $passed_tag_atts); |
|
| 384 | 384 | |
| 385 | 385 | /** |
| 386 | 386 | * @filter `gravityview_field_entry_link` Modify the link HTML |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * @param array $entry The GF entry array |
| 390 | 390 | * @param array $field_settings Settings for the particular GV field |
| 391 | 391 | */ |
| 392 | - $output = apply_filters( 'gravityview_field_entry_link', $link, $href, $entry, $field_settings ); |
|
| 392 | + $output = apply_filters('gravityview_field_entry_link', $link, $href, $entry, $field_settings); |
|
| 393 | 393 | |
| 394 | 394 | return $output; |
| 395 | 395 | } |
@@ -404,11 +404,11 @@ discard block |
||
| 404 | 404 | |
| 405 | 405 | $is_search = false; |
| 406 | 406 | |
| 407 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
| 407 | + if ($gravityview_view && ($gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search)) { |
|
| 408 | 408 | $is_search = true; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if($is_search) { |
|
| 411 | + if ($is_search) { |
|
| 412 | 412 | $output = __('This search returned no results.', 'gravityview'); |
| 413 | 413 | } else { |
| 414 | 414 | $output = __('No entries match your request.', 'gravityview'); |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | * @param string $output The existing "No Entries" text |
| 420 | 420 | * @param boolean $is_search Is the current page a search result, or just a multiple entries screen? |
| 421 | 421 | */ |
| 422 | - $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search); |
|
| 422 | + $output = apply_filters('gravitview_no_entries_text', $output, $is_search); |
|
| 423 | 423 | |
| 424 | 424 | return $wpautop ? wpautop($output) : $output; |
| 425 | 425 | } |
@@ -433,42 +433,42 @@ discard block |
||
| 433 | 433 | * @param boolean $add_query_args Add pagination and sorting arguments |
| 434 | 434 | * @return string Permalink to multiple entries view |
| 435 | 435 | */ |
| 436 | - public static function directory_link( $post_id = NULL, $add_query_args = true ) { |
|
| 436 | + public static function directory_link($post_id = NULL, $add_query_args = true) { |
|
| 437 | 437 | global $post; |
| 438 | 438 | |
| 439 | 439 | $gravityview_view = GravityView_View::getInstance(); |
| 440 | 440 | |
| 441 | - if( empty( $post_id ) ) { |
|
| 441 | + if (empty($post_id)) { |
|
| 442 | 442 | |
| 443 | 443 | $post_id = false; |
| 444 | 444 | |
| 445 | 445 | // DataTables passes the Post ID |
| 446 | - if( defined('DOING_AJAX') && DOING_AJAX ) { |
|
| 446 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 447 | 447 | |
| 448 | - $post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false; |
|
| 448 | + $post_id = isset($_POST['post_id']) ? (int)$_POST['post_id'] : false; |
|
| 449 | 449 | |
| 450 | 450 | } else { |
| 451 | 451 | |
| 452 | 452 | // The Post ID has been passed via the shortcode |
| 453 | - if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
| 453 | + if (!empty($gravityview_view) && $gravityview_view->getPostId()) { |
|
| 454 | 454 | |
| 455 | 455 | $post_id = $gravityview_view->getPostId(); |
| 456 | 456 | |
| 457 | 457 | } else { |
| 458 | 458 | |
| 459 | 459 | // This is a GravityView post type |
| 460 | - if( GravityView_frontend::getInstance()->isGravityviewPostType() ) { |
|
| 460 | + if (GravityView_frontend::getInstance()->isGravityviewPostType()) { |
|
| 461 | 461 | |
| 462 | - $post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID; |
|
| 462 | + $post_id = isset($gravityview_view) ? $gravityview_view->getViewId() : $post->ID; |
|
| 463 | 463 | |
| 464 | 464 | } else { |
| 465 | 465 | |
| 466 | 466 | // This is an embedded GravityView; use the embedded post's ID as the base. |
| 467 | - if( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) { |
|
| 467 | + if (GravityView_frontend::getInstance()->isPostHasShortcode() && is_a($post, 'WP_Post')) { |
|
| 468 | 468 | |
| 469 | 469 | $post_id = $post->ID; |
| 470 | 470 | |
| 471 | - } elseif( $gravityview_view->getViewId() ) { |
|
| 471 | + } elseif ($gravityview_view->getViewId()) { |
|
| 472 | 472 | |
| 473 | 473 | // The GravityView has been embedded in a widget or in a template, and |
| 474 | 474 | // is not in the current content. Thus, we defer to the View's own ID. |
@@ -483,39 +483,39 @@ discard block |
||
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | // No post ID, get outta here. |
| 486 | - if( empty( $post_id ) ) { |
|
| 486 | + if (empty($post_id)) { |
|
| 487 | 487 | return NULL; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | // If we've saved the permalink in memory, use it |
| 491 | 491 | // @since 1.3 |
| 492 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
| 492 | + $link = wp_cache_get('gv_directory_link_'.$post_id); |
|
| 493 | 493 | |
| 494 | - if( empty( $link ) ) { |
|
| 494 | + if (empty($link)) { |
|
| 495 | 495 | |
| 496 | - $link = get_permalink( $post_id ); |
|
| 496 | + $link = get_permalink($post_id); |
|
| 497 | 497 | |
| 498 | 498 | // If not yet saved, cache the permalink. |
| 499 | 499 | // @since 1.3 |
| 500 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
| 500 | + wp_cache_set('gv_directory_link_'.$post_id, $link); |
|
| 501 | 501 | |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | // Deal with returning to proper pagination for embedded views |
| 505 | - if( $link && $add_query_args ) { |
|
| 505 | + if ($link && $add_query_args) { |
|
| 506 | 506 | |
| 507 | 507 | $args = array(); |
| 508 | 508 | |
| 509 | - if( $pagenum = rgget('pagenum') ) { |
|
| 510 | - $args['pagenum'] = intval( $pagenum ); |
|
| 509 | + if ($pagenum = rgget('pagenum')) { |
|
| 510 | + $args['pagenum'] = intval($pagenum); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - if( $sort = rgget('sort') ) { |
|
| 513 | + if ($sort = rgget('sort')) { |
|
| 514 | 514 | $args['sort'] = $sort; |
| 515 | 515 | $args['dir'] = rgget('dir'); |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - $link = add_query_arg( $args, $link ); |
|
| 518 | + $link = add_query_arg($args, $link); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | return $link; |
@@ -532,10 +532,10 @@ discard block |
||
| 532 | 532 | * @param array $entry Entry data passed to provide additional information when generating the hash. Optional - don't rely on it being available. |
| 533 | 533 | * @return string Hashed unique value for entry |
| 534 | 534 | */ |
| 535 | - private static function get_custom_entry_slug( $id, $entry = array() ) { |
|
| 535 | + private static function get_custom_entry_slug($id, $entry = array()) { |
|
| 536 | 536 | |
| 537 | 537 | // Generate an unique hash to use as the default value |
| 538 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
| 538 | + $slug = substr(wp_hash($id, 'gravityview'.$id), 0, 8); |
|
| 539 | 539 | |
| 540 | 540 | /** |
| 541 | 541 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -543,14 +543,14 @@ discard block |
||
| 543 | 543 | * @param string $id The entry ID |
| 544 | 544 | * @param array $entry Entry data array. May be empty. |
| 545 | 545 | */ |
| 546 | - $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
|
| 546 | + $slug = apply_filters('gravityview_entry_slug', $slug, $id, $entry); |
|
| 547 | 547 | |
| 548 | 548 | // Make sure we have something - use the original ID as backup. |
| 549 | - if( empty( $slug ) ) { |
|
| 549 | + if (empty($slug)) { |
|
| 550 | 550 | $slug = $id; |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - return sanitize_title( $slug ); |
|
| 553 | + return sanitize_title($slug); |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | /** |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | * @param array $entry Gravity Forms Entry array, optional. Used only to provide data to customize the `gravityview_entry_slug` filter |
| 565 | 565 | * @return string Unique slug ID, passed through `sanitize_title()` |
| 566 | 566 | */ |
| 567 | - public static function get_entry_slug( $id_or_string, $entry = array() ) { |
|
| 567 | + public static function get_entry_slug($id_or_string, $entry = array()) { |
|
| 568 | 568 | |
| 569 | 569 | /** |
| 570 | 570 | * Default: use the entry ID as the unique identifier |
@@ -575,32 +575,32 @@ discard block |
||
| 575 | 575 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
| 576 | 576 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
| 577 | 577 | */ |
| 578 | - $custom = apply_filters('gravityview_custom_entry_slug', false ); |
|
| 578 | + $custom = apply_filters('gravityview_custom_entry_slug', false); |
|
| 579 | 579 | |
| 580 | 580 | // If we're using custom slug... |
| 581 | - if ( $custom ) { |
|
| 581 | + if ($custom) { |
|
| 582 | 582 | |
| 583 | 583 | // Get the entry hash |
| 584 | - $hash = self::get_custom_entry_slug( $id_or_string, $entry ); |
|
| 584 | + $hash = self::get_custom_entry_slug($id_or_string, $entry); |
|
| 585 | 585 | |
| 586 | 586 | // See if the entry already has a hash set |
| 587 | - $value = gform_get_meta( $id_or_string, 'gravityview_unique_id' ); |
|
| 587 | + $value = gform_get_meta($id_or_string, 'gravityview_unique_id'); |
|
| 588 | 588 | |
| 589 | 589 | // If it does have a hash set, and the hash is expected, use it. |
| 590 | 590 | // This check allows users to change the hash structure using the |
| 591 | 591 | // gravityview_entry_hash filter and have the old hashes expire. |
| 592 | - if( empty( $value ) || $value !== $hash ) { |
|
| 592 | + if (empty($value) || $value !== $hash) { |
|
| 593 | 593 | |
| 594 | - gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash ); |
|
| 594 | + gform_update_meta($id_or_string, 'gravityview_unique_id', $hash); |
|
| 595 | 595 | |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | $slug = $hash; |
| 599 | 599 | |
| 600 | - unset( $value, $hash ); |
|
| 600 | + unset($value, $hash); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - return sanitize_title( $slug ); |
|
| 603 | + return sanitize_title($slug); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | /** |
@@ -611,18 +611,18 @@ discard block |
||
| 611 | 611 | * @param $entry array Gravity Forms entry object |
| 612 | 612 | * @param $form array Gravity Forms form object |
| 613 | 613 | */ |
| 614 | - public static function entry_create_custom_slug( $entry, $form ) { |
|
| 614 | + public static function entry_create_custom_slug($entry, $form) { |
|
| 615 | 615 | /** |
| 616 | 616 | * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta |
| 617 | 617 | * @param boolean $custom Should we process the custom entry slug? |
| 618 | 618 | */ |
| 619 | - $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
| 620 | - if( $custom ) { |
|
| 619 | + $custom = apply_filters('gravityview_custom_entry_slug', false); |
|
| 620 | + if ($custom) { |
|
| 621 | 621 | // create the gravityview_unique_id and save it |
| 622 | 622 | |
| 623 | 623 | // Get the entry hash |
| 624 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
| 625 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
| 624 | + $hash = self::get_custom_entry_slug($entry['id'], $entry); |
|
| 625 | + gform_update_meta($entry['id'], 'gravityview_unique_id', $hash); |
|
| 626 | 626 | |
| 627 | 627 | } |
| 628 | 628 | } |
@@ -637,55 +637,55 @@ discard block |
||
| 637 | 637 | * @param boolean $add_directory_args True: Add args to help return to directory; False: only include args required to get to entry {@since 1.7.3} |
| 638 | 638 | * @return string Link to the entry with the directory parent slug |
| 639 | 639 | */ |
| 640 | - public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) { |
|
| 640 | + public static function entry_link($entry, $post_id = NULL, $add_directory_args = true) { |
|
| 641 | 641 | |
| 642 | - if( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
| 643 | - $entry = GVCommon::get_entry( $entry ); |
|
| 644 | - } else if( empty( $entry ) ) { |
|
| 642 | + if (!empty($entry) && !is_array($entry)) { |
|
| 643 | + $entry = GVCommon::get_entry($entry); |
|
| 644 | + } else if (empty($entry)) { |
|
| 645 | 645 | $entry = GravityView_frontend::getInstance()->getEntry(); |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | // Second parameter used to be passed as $field; this makes sure it's not an array |
| 649 | - if( !is_numeric( $post_id ) ) { |
|
| 649 | + if (!is_numeric($post_id)) { |
|
| 650 | 650 | $post_id = NULL; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | // Get the permalink to the View |
| 654 | - $directory_link = self::directory_link( $post_id, false ); |
|
| 654 | + $directory_link = self::directory_link($post_id, false); |
|
| 655 | 655 | |
| 656 | 656 | // No post ID? Get outta here. |
| 657 | - if( empty( $directory_link ) ) { |
|
| 657 | + if (empty($directory_link)) { |
|
| 658 | 658 | return ''; |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | $query_arg_name = GravityView_Post_Types::get_entry_var_name(); |
| 662 | 662 | |
| 663 | - $entry_slug = self::get_entry_slug( $entry['id'], $entry ); |
|
| 663 | + $entry_slug = self::get_entry_slug($entry['id'], $entry); |
|
| 664 | 664 | |
| 665 | - if( get_option('permalink_structure') && !is_preview() ) { |
|
| 665 | + if (get_option('permalink_structure') && !is_preview()) { |
|
| 666 | 666 | |
| 667 | 667 | $args = array(); |
| 668 | 668 | |
| 669 | - $directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/'. $entry_slug .'/'; |
|
| 669 | + $directory_link = trailingslashit($directory_link).$query_arg_name.'/'.$entry_slug.'/'; |
|
| 670 | 670 | |
| 671 | 671 | } else { |
| 672 | 672 | |
| 673 | - $args = array( $query_arg_name => $entry_slug ); |
|
| 673 | + $args = array($query_arg_name => $entry_slug); |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
| 677 | 677 | * @since 1.7.3 |
| 678 | 678 | */ |
| 679 | - if( $add_directory_args ) { |
|
| 679 | + if ($add_directory_args) { |
|
| 680 | 680 | |
| 681 | - if( !empty( $_GET['pagenum'] ) ) { |
|
| 682 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
| 681 | + if (!empty($_GET['pagenum'])) { |
|
| 682 | + $args['pagenum'] = intval($_GET['pagenum']); |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | /** |
| 686 | 686 | * @since 1.7 |
| 687 | 687 | */ |
| 688 | - if( $sort = rgget('sort') ) { |
|
| 688 | + if ($sort = rgget('sort')) { |
|
| 689 | 689 | $args['sort'] = $sort; |
| 690 | 690 | $args['dir'] = rgget('dir'); |
| 691 | 691 | } |
@@ -697,11 +697,11 @@ discard block |
||
| 697 | 697 | * has the view id so that Advanced Filters can be applied correctly when rendering the single view |
| 698 | 698 | * @see GravityView_frontend::get_context_view_id() |
| 699 | 699 | */ |
| 700 | - if( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
|
| 700 | + if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views()) { |
|
| 701 | 701 | $args['gvid'] = gravityview_get_view_id(); |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - return add_query_arg( $args, $directory_link ); |
|
| 704 | + return add_query_arg($args, $directory_link); |
|
| 705 | 705 | |
| 706 | 706 | } |
| 707 | 707 | |
@@ -711,12 +711,12 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | // inside loop functions |
| 713 | 713 | |
| 714 | -function gv_label( $field, $entry = NULL ) { |
|
| 715 | - return GravityView_API::field_label( $field, $entry ); |
|
| 714 | +function gv_label($field, $entry = NULL) { |
|
| 715 | + return GravityView_API::field_label($field, $entry); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | -function gv_class( $field, $form = NULL, $entry = array() ) { |
|
| 719 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
| 718 | +function gv_class($field, $form = NULL, $entry = array()) { |
|
| 719 | + return GravityView_API::field_class($field, $form, $entry); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | /** |
@@ -730,61 +730,61 @@ discard block |
||
| 730 | 730 | * |
| 731 | 731 | * @return string CSS class, sanitized by gravityview_sanitize_html_class() |
| 732 | 732 | */ |
| 733 | -function gv_container_class( $passed_css_class = '', $echo = true ) { |
|
| 733 | +function gv_container_class($passed_css_class = '', $echo = true) { |
|
| 734 | 734 | |
| 735 | - $passed_css_class = trim( $passed_css_class ); |
|
| 735 | + $passed_css_class = trim($passed_css_class); |
|
| 736 | 736 | |
| 737 | 737 | $view_id = GravityView_View::getInstance()->getViewId(); |
| 738 | 738 | |
| 739 | - $default_css_class = ! empty( $view_id ) ? sprintf( 'gv-container gv-container-%d', $view_id ) : 'gv-container'; |
|
| 739 | + $default_css_class = !empty($view_id) ? sprintf('gv-container gv-container-%d', $view_id) : 'gv-container'; |
|
| 740 | 740 | |
| 741 | - if( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
| 741 | + if (GravityView_View::getInstance()->isHideUntilSearched()) { |
|
| 742 | 742 | $default_css_class .= ' hidden'; |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | - $css_class = trim( $passed_css_class . ' '. $default_css_class ); |
|
| 745 | + $css_class = trim($passed_css_class.' '.$default_css_class); |
|
| 746 | 746 | |
| 747 | 747 | /** |
| 748 | 748 | * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View |
| 749 | 749 | * @since 1.5.4 |
| 750 | 750 | * @param[in,out] string $css_class Default: `gv-container gv-container-{view id}`. If View is hidden until search, adds ` hidden` |
| 751 | 751 | */ |
| 752 | - $css_class = apply_filters( 'gravityview/render/container/class', $css_class ); |
|
| 752 | + $css_class = apply_filters('gravityview/render/container/class', $css_class); |
|
| 753 | 753 | |
| 754 | - $css_class = gravityview_sanitize_html_class( $css_class ); |
|
| 754 | + $css_class = gravityview_sanitize_html_class($css_class); |
|
| 755 | 755 | |
| 756 | - if( $echo ) { |
|
| 756 | + if ($echo) { |
|
| 757 | 757 | echo $css_class; |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | return $css_class; |
| 761 | 761 | } |
| 762 | 762 | |
| 763 | -function gv_value( $entry, $field ) { |
|
| 763 | +function gv_value($entry, $field) { |
|
| 764 | 764 | |
| 765 | - $value = GravityView_API::field_value( $entry, $field ); |
|
| 765 | + $value = GravityView_API::field_value($entry, $field); |
|
| 766 | 766 | |
| 767 | - if( $value === '') { |
|
| 767 | + if ($value === '') { |
|
| 768 | 768 | /** |
| 769 | 769 | * @filter `gravityview_empty_value` What to display when a field is empty |
| 770 | 770 | * @param string $value (empty string) |
| 771 | 771 | */ |
| 772 | - $value = apply_filters( 'gravityview_empty_value', '' ); |
|
| 772 | + $value = apply_filters('gravityview_empty_value', ''); |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | return $value; |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | -function gv_directory_link( $post = NULL, $add_pagination = true ) { |
|
| 779 | - return GravityView_API::directory_link( $post, $add_pagination ); |
|
| 778 | +function gv_directory_link($post = NULL, $add_pagination = true) { |
|
| 779 | + return GravityView_API::directory_link($post, $add_pagination); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | -function gv_entry_link( $entry, $post_id = NULL ) { |
|
| 783 | - return GravityView_API::entry_link( $entry, $post_id ); |
|
| 782 | +function gv_entry_link($entry, $post_id = NULL) { |
|
| 783 | + return GravityView_API::entry_link($entry, $post_id); |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | function gv_no_results($wpautop = true) { |
| 787 | - return GravityView_API::no_results( $wpautop ); |
|
| 787 | + return GravityView_API::no_results($wpautop); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | /** |
@@ -796,21 +796,21 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | $href = gv_directory_link(); |
| 798 | 798 | |
| 799 | - if( empty( $href ) ) { return NULL; } |
|
| 799 | + if (empty($href)) { return NULL; } |
|
| 800 | 800 | |
| 801 | 801 | // calculate link label |
| 802 | 802 | $gravityview_view = GravityView_View::getInstance(); |
| 803 | 803 | |
| 804 | - $label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __( '← Go back', 'gravityview' ); |
|
| 804 | + $label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __('← Go back', 'gravityview'); |
|
| 805 | 805 | |
| 806 | 806 | /** |
| 807 | 807 | * @filter `gravityview_go_back_label` Modify the back link text |
| 808 | 808 | * @since 1.0.9 |
| 809 | 809 | * @param string $label Existing label text |
| 810 | 810 | */ |
| 811 | - $label = apply_filters( 'gravityview_go_back_label', $label ); |
|
| 811 | + $label = apply_filters('gravityview_go_back_label', $label); |
|
| 812 | 812 | |
| 813 | - $link = gravityview_get_link( $href, esc_html( $label ), array( |
|
| 813 | + $link = gravityview_get_link($href, esc_html($label), array( |
|
| 814 | 814 | 'data-viewid' => $gravityview_view->getViewId() |
| 815 | 815 | )); |
| 816 | 816 | |
@@ -829,9 +829,9 @@ discard block |
||
| 829 | 829 | * @param string $display_value The value generated by Gravity Forms |
| 830 | 830 | * @return string Value |
| 831 | 831 | */ |
| 832 | -function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
|
| 832 | +function gravityview_get_field_value($entry, $field_id, $display_value) { |
|
| 833 | 833 | |
| 834 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
| 834 | + if (floatval($field_id) === floor(floatval($field_id))) { |
|
| 835 | 835 | |
| 836 | 836 | // For the complete field value as generated by Gravity Forms |
| 837 | 837 | return $display_value; |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | } else { |
| 840 | 840 | |
| 841 | 841 | // For one part of the address (City, ZIP, etc.) |
| 842 | - return isset( $entry[ $field_id ] ) ? $entry[ $field_id ] : ''; |
|
| 842 | + return isset($entry[$field_id]) ? $entry[$field_id] : ''; |
|
| 843 | 843 | |
| 844 | 844 | } |
| 845 | 845 | |
@@ -855,48 +855,48 @@ discard block |
||
| 855 | 855 | * @param string $taxonomy Type of term (`post_tag` or `category`) |
| 856 | 856 | * @return string CSV of linked terms |
| 857 | 857 | */ |
| 858 | -function gravityview_convert_value_to_term_list( $value, $taxonomy = 'post_tag' ) { |
|
| 858 | +function gravityview_convert_value_to_term_list($value, $taxonomy = 'post_tag') { |
|
| 859 | 859 | |
| 860 | 860 | $output = array(); |
| 861 | 861 | |
| 862 | - $terms = explode( ', ', $value ); |
|
| 862 | + $terms = explode(', ', $value); |
|
| 863 | 863 | |
| 864 | - foreach ($terms as $term_name ) { |
|
| 864 | + foreach ($terms as $term_name) { |
|
| 865 | 865 | |
| 866 | 866 | // If we're processing a category, |
| 867 | - if( $taxonomy === 'category' ) { |
|
| 867 | + if ($taxonomy === 'category') { |
|
| 868 | 868 | |
| 869 | 869 | // Use rgexplode to prevent errors if : doesn't exist |
| 870 | - list( $term_name, $term_id ) = rgexplode( ':', $value, 2 ); |
|
| 870 | + list($term_name, $term_id) = rgexplode(':', $value, 2); |
|
| 871 | 871 | |
| 872 | 872 | // The explode was succesful; we have the category ID |
| 873 | - if( !empty( $term_id )) { |
|
| 874 | - $term = get_term_by( 'id', $term_id, $taxonomy ); |
|
| 873 | + if (!empty($term_id)) { |
|
| 874 | + $term = get_term_by('id', $term_id, $taxonomy); |
|
| 875 | 875 | } else { |
| 876 | 876 | // We have to fall back to the name |
| 877 | - $term = get_term_by( 'name', $term_name, $taxonomy ); |
|
| 877 | + $term = get_term_by('name', $term_name, $taxonomy); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | } else { |
| 881 | 881 | // Use the name of the tag to get the full term information |
| 882 | - $term = get_term_by( 'name', $term_name, $taxonomy ); |
|
| 882 | + $term = get_term_by('name', $term_name, $taxonomy); |
|
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | // There's still a tag/category here. |
| 886 | - if( $term ) { |
|
| 886 | + if ($term) { |
|
| 887 | 887 | |
| 888 | - $term_link = get_term_link( $term, $taxonomy ); |
|
| 888 | + $term_link = get_term_link($term, $taxonomy); |
|
| 889 | 889 | |
| 890 | 890 | // If there was an error, continue to the next term. |
| 891 | - if ( is_wp_error( $term_link ) ) { |
|
| 891 | + if (is_wp_error($term_link)) { |
|
| 892 | 892 | continue; |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
| 895 | + $output[] = gravityview_get_link($term_link, esc_html($term->name)); |
|
| 896 | 896 | } |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - return implode(', ', $output ); |
|
| 899 | + return implode(', ', $output); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | /** |
@@ -906,12 +906,12 @@ discard block |
||
| 906 | 906 | * @param string $taxonomy Taxonomy of term to fetch. |
| 907 | 907 | * @return string String with terms |
| 908 | 908 | */ |
| 909 | -function gravityview_get_the_term_list( $post_id, $link = true, $taxonomy = 'post_tag' ) { |
|
| 909 | +function gravityview_get_the_term_list($post_id, $link = true, $taxonomy = 'post_tag') { |
|
| 910 | 910 | |
| 911 | - $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
|
| 911 | + $output = get_the_term_list($post_id, $taxonomy, NULL, ', '); |
|
| 912 | 912 | |
| 913 | - if( empty( $link ) ) { |
|
| 914 | - return strip_tags( $output); |
|
| 913 | + if (empty($link)) { |
|
| 914 | + return strip_tags($output); |
|
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | return $output; |
@@ -930,17 +930,17 @@ discard block |
||
| 930 | 930 | $fe = GravityView_frontend::getInstance(); |
| 931 | 931 | |
| 932 | 932 | // Solve problem when loading content via admin-ajax.php |
| 933 | - if( ! $fe->getGvOutputData() ) { |
|
| 933 | + if (!$fe->getGvOutputData()) { |
|
| 934 | 934 | |
| 935 | - do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' ); |
|
| 935 | + do_action('gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.'); |
|
| 936 | 936 | |
| 937 | 937 | $fe->parse_content(); |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | // Make 100% sure that we're dealing with a properly called situation |
| 941 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
| 941 | + if (!is_a($fe->getGvOutputData(), 'GravityView_View_Data')) { |
|
| 942 | 942 | |
| 943 | - do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() ); |
|
| 943 | + do_action('gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData()); |
|
| 944 | 944 | |
| 945 | 945 | return array(); |
| 946 | 946 | } |
@@ -954,18 +954,18 @@ discard block |
||
| 954 | 954 | * @see GravityView_View_Data::get_view() |
| 955 | 955 | * @return array View data with `id`, `view_id`, `form_id`, `template_id`, `atts`, `fields`, `widgets`, `form` keys. |
| 956 | 956 | */ |
| 957 | -function gravityview_get_current_view_data( $view_id = 0 ) { |
|
| 957 | +function gravityview_get_current_view_data($view_id = 0) { |
|
| 958 | 958 | |
| 959 | 959 | $fe = GravityView_frontend::getInstance(); |
| 960 | 960 | |
| 961 | - if( ! $fe->getGvOutputData() ) { return array(); } |
|
| 961 | + if (!$fe->getGvOutputData()) { return array(); } |
|
| 962 | 962 | |
| 963 | 963 | // If not set, grab the current view ID |
| 964 | - if( empty( $view_id ) ) { |
|
| 964 | + if (empty($view_id)) { |
|
| 965 | 965 | $view_id = $fe->get_context_view_id(); |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | - return $fe->getGvOutputData()->get_view( $view_id ); |
|
| 968 | + return $fe->getGvOutputData()->get_view($view_id); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | // Templates' hooks |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | * @action `gravityview_before` Display content before a View. Used to render widget areas. Rendered outside the View container `<div>` |
| 975 | 975 | * @param int $view_id The ID of the View being displayed |
| 976 | 976 | */ |
| 977 | - do_action( 'gravityview_before', gravityview_get_view_id() ); |
|
| 977 | + do_action('gravityview_before', gravityview_get_view_id()); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | function gravityview_header() { |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | * @action `gravityview_header` Prepend content to the View container `<div>` |
| 983 | 983 | * @param int $view_id The ID of the View being displayed |
| 984 | 984 | */ |
| 985 | - do_action( 'gravityview_header', gravityview_get_view_id() ); |
|
| 985 | + do_action('gravityview_header', gravityview_get_view_id()); |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | function gravityview_footer() { |
@@ -990,7 +990,7 @@ discard block |
||
| 990 | 990 | * @action `gravityview_after` Display content after a View. Used to render footer widget areas. Rendered outside the View container `<div>` |
| 991 | 991 | * @param int $view_id The ID of the View being displayed |
| 992 | 992 | */ |
| 993 | - do_action( 'gravityview_footer', gravityview_get_view_id() ); |
|
| 993 | + do_action('gravityview_footer', gravityview_get_view_id()); |
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | function gravityview_after() { |
@@ -998,7 +998,7 @@ discard block |
||
| 998 | 998 | * @action `gravityview_after` Append content to the View container `<div>` |
| 999 | 999 | * @param int $view_id The ID of the View being displayed |
| 1000 | 1000 | */ |
| 1001 | - do_action( 'gravityview_after', gravityview_get_view_id() ); |
|
| 1001 | + do_action('gravityview_after', gravityview_get_view_id()); |
|
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | /** |
@@ -1024,13 +1024,13 @@ discard block |
||
| 1024 | 1024 | * The Edit Entry functionality overrides this value. |
| 1025 | 1025 | * @param boolean $is_edit_entry |
| 1026 | 1026 | */ |
| 1027 | - $is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false ); |
|
| 1027 | + $is_edit_entry = apply_filters('gravityview_is_edit_entry', false); |
|
| 1028 | 1028 | |
| 1029 | - if( $is_edit_entry ) { |
|
| 1029 | + if ($is_edit_entry) { |
|
| 1030 | 1030 | $context = 'edit'; |
| 1031 | - } else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
| 1031 | + } else if (class_exists('GravityView_frontend') && $single = GravityView_frontend::is_single_entry()) { |
|
| 1032 | 1032 | $context = 'single'; |
| 1033 | - } else if( class_exists( 'GravityView_View' ) ) { |
|
| 1033 | + } else if (class_exists('GravityView_View')) { |
|
| 1034 | 1034 | $context = GravityView_View::getInstance()->getContext(); |
| 1035 | 1035 | } |
| 1036 | 1036 | |
@@ -1055,18 +1055,18 @@ discard block |
||
| 1055 | 1055 | * @param string $gv_class Field class to add to the output HTML |
| 1056 | 1056 | * @return array Array of file output, with `file_path` and `html` keys (see comments above) |
| 1057 | 1057 | */ |
| 1058 | -function gravityview_get_files_array( $value, $gv_class = '' ) { |
|
| 1058 | +function gravityview_get_files_array($value, $gv_class = '') { |
|
| 1059 | 1059 | /** @define "GRAVITYVIEW_DIR" "../" */ |
| 1060 | 1060 | |
| 1061 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
| 1062 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
| 1061 | + if (!class_exists('GravityView_Field')) { |
|
| 1062 | + include_once(GRAVITYVIEW_DIR.'includes/fields/class-gravityview-field.php'); |
|
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
| 1066 | - include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' ); |
|
| 1065 | + if (!class_exists('GravityView_Field_FileUpload')) { |
|
| 1066 | + include_once(GRAVITYVIEW_DIR.'includes/fields/fileupload.php'); |
|
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | - return GravityView_Field_FileUpload::get_files_array( $value, $gv_class ); |
|
| 1069 | + return GravityView_Field_FileUpload::get_files_array($value, $gv_class); |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | /** |
@@ -1080,16 +1080,16 @@ discard block |
||
| 1080 | 1080 | * @param string $address Address |
| 1081 | 1081 | * @return string URL of link to map of address |
| 1082 | 1082 | */ |
| 1083 | -function gravityview_get_map_link( $address ) { |
|
| 1083 | +function gravityview_get_map_link($address) { |
|
| 1084 | 1084 | |
| 1085 | - $address_qs = str_replace( array( '<br />', "\n" ), ' ', $address ); // Replace \n with spaces |
|
| 1086 | - $address_qs = urlencode( $address_qs ); |
|
| 1085 | + $address_qs = str_replace(array('<br />', "\n"), ' ', $address); // Replace \n with spaces |
|
| 1086 | + $address_qs = urlencode($address_qs); |
|
| 1087 | 1087 | |
| 1088 | 1088 | $url = "https://maps.google.com/maps?q={$address_qs}"; |
| 1089 | 1089 | |
| 1090 | - $link_text = esc_html__( 'Map It', 'gravityview' ); |
|
| 1090 | + $link_text = esc_html__('Map It', 'gravityview'); |
|
| 1091 | 1091 | |
| 1092 | - $link = gravityview_get_link( $url, $link_text, 'class=map-it-link' ); |
|
| 1092 | + $link = gravityview_get_link($url, $link_text, 'class=map-it-link'); |
|
| 1093 | 1093 | |
| 1094 | 1094 | /** |
| 1095 | 1095 | * @filter `gravityview_map_link` Modify the map link generated. You can use a different mapping service, for example. |
@@ -1097,7 +1097,7 @@ discard block |
||
| 1097 | 1097 | * @param[in] string $address Address to generate link for |
| 1098 | 1098 | * @param[in] string $url URL generated by the function |
| 1099 | 1099 | */ |
| 1100 | - $link = apply_filters( 'gravityview_map_link', $link, $address, $url ); |
|
| 1100 | + $link = apply_filters('gravityview_map_link', $link, $address, $url); |
|
| 1101 | 1101 | |
| 1102 | 1102 | return $link; |
| 1103 | 1103 | } |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | * @param array $passed_args Associative array with field data. `field` and `form` are required. |
| 1119 | 1119 | * @return string Field output. If empty value and hide empty is true, return empty. |
| 1120 | 1120 | */ |
| 1121 | -function gravityview_field_output( $passed_args ) { |
|
| 1121 | +function gravityview_field_output($passed_args) { |
|
| 1122 | 1122 | $defaults = array( |
| 1123 | 1123 | 'entry' => null, |
| 1124 | 1124 | 'field' => null, |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | 'zone_id' => null, |
| 1131 | 1131 | ); |
| 1132 | 1132 | |
| 1133 | - $args = wp_parse_args( $passed_args, $defaults ); |
|
| 1133 | + $args = wp_parse_args($passed_args, $defaults); |
|
| 1134 | 1134 | |
| 1135 | 1135 | /** |
| 1136 | 1136 | * @filter `gravityview/field_output/args` Modify the args before generation begins |
@@ -1138,15 +1138,15 @@ discard block |
||
| 1138 | 1138 | * @param array $args Associative array; `field` and `form` is required. |
| 1139 | 1139 | * @param array $passed_args Original associative array with field data. `field` and `form` are required. |
| 1140 | 1140 | */ |
| 1141 | - $args = apply_filters( 'gravityview/field_output/args', $args, $passed_args ); |
|
| 1141 | + $args = apply_filters('gravityview/field_output/args', $args, $passed_args); |
|
| 1142 | 1142 | |
| 1143 | 1143 | // Required fields. |
| 1144 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
| 1145 | - do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args ); |
|
| 1144 | + if (empty($args['field']) || empty($args['form'])) { |
|
| 1145 | + do_action('gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args); |
|
| 1146 | 1146 | return ''; |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
| 1149 | + $entry = empty($args['entry']) ? array() : $args['entry']; |
|
| 1150 | 1150 | |
| 1151 | 1151 | /** |
| 1152 | 1152 | * Create the content variables for replacing. |
@@ -1162,36 +1162,36 @@ discard block |
||
| 1162 | 1162 | 'field_id' => '', |
| 1163 | 1163 | ); |
| 1164 | 1164 | |
| 1165 | - $context['value'] = gv_value( $entry, $args['field'] ); |
|
| 1165 | + $context['value'] = gv_value($entry, $args['field']); |
|
| 1166 | 1166 | |
| 1167 | 1167 | // If the value is empty and we're hiding empty, return empty. |
| 1168 | - if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
| 1168 | + if ($context['value'] === '' && !empty($args['hide_empty'])) { |
|
| 1169 | 1169 | return ''; |
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | - if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
| 1173 | - $context['value'] = wpautop( $context['value'] ); |
|
| 1172 | + if ($context['value'] !== '' && !empty($args['wpautop'])) { |
|
| 1173 | + $context['value'] = wpautop($context['value']); |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | // Get width setting, if exists |
| 1177 | - $context['width'] = GravityView_API::field_width( $args['field'] ); |
|
| 1177 | + $context['width'] = GravityView_API::field_width($args['field']); |
|
| 1178 | 1178 | |
| 1179 | 1179 | // If replacing with CSS inline formatting, let's do it. |
| 1180 | - $context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' ); |
|
| 1180 | + $context['width:style'] = GravityView_API::field_width($args['field'], 'width:'.$context['width'].'%;'); |
|
| 1181 | 1181 | |
| 1182 | 1182 | // Grab the Class using `gv_class` |
| 1183 | - $context['class'] = gv_class( $args['field'], $args['form'], $entry ); |
|
| 1184 | - $context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry ); |
|
| 1183 | + $context['class'] = gv_class($args['field'], $args['form'], $entry); |
|
| 1184 | + $context['field_id'] = GravityView_API::field_html_attr_id($args['field'], $args['form'], $entry); |
|
| 1185 | 1185 | |
| 1186 | 1186 | // Get field label if needed |
| 1187 | - if ( ! empty( $args['label_markup'] ) && ! empty( $args['field']['show_label'] ) ) { |
|
| 1188 | - $context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] ); |
|
| 1187 | + if (!empty($args['label_markup']) && !empty($args['field']['show_label'])) { |
|
| 1188 | + $context['label'] = str_replace(array('{{label}}', '{{ label }}'), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup']); |
|
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | // Default Label value |
| 1192 | - $context['label_value'] = gv_label( $args['field'], $entry ); |
|
| 1192 | + $context['label_value'] = gv_label($args['field'], $entry); |
|
| 1193 | 1193 | |
| 1194 | - if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){ |
|
| 1194 | + if (empty($context['label']) && !empty($context['label_value'])) { |
|
| 1195 | 1195 | $context['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
| 1196 | 1196 | } |
| 1197 | 1197 | |
@@ -1201,37 +1201,37 @@ discard block |
||
| 1201 | 1201 | * @param string $markup The HTML for the markup |
| 1202 | 1202 | * @param array $args All args for the field output |
| 1203 | 1203 | */ |
| 1204 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args ); |
|
| 1204 | + $html = apply_filters('gravityview/field_output/pre_html', $args['markup'], $args); |
|
| 1205 | 1205 | |
| 1206 | 1206 | /** |
| 1207 | 1207 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
| 1208 | 1208 | * @since 1.11 |
| 1209 | 1209 | * @param string $open_tag Open tag for template content placeholders. Default: `{{` |
| 1210 | 1210 | */ |
| 1211 | - $open_tag = apply_filters( 'gravityview/field_output/open_tag', '{{', $args ); |
|
| 1211 | + $open_tag = apply_filters('gravityview/field_output/open_tag', '{{', $args); |
|
| 1212 | 1212 | |
| 1213 | 1213 | /** |
| 1214 | 1214 | * @filter `gravityview/field_output/close_tag` Modify the closing tags for the template content placeholders |
| 1215 | 1215 | * @since 1.11 |
| 1216 | 1216 | * @param string $close_tag Close tag for template content placeholders. Default: `}}` |
| 1217 | 1217 | */ |
| 1218 | - $close_tag = apply_filters( 'gravityview/field_output/close_tag', '}}', $args ); |
|
| 1218 | + $close_tag = apply_filters('gravityview/field_output/close_tag', '}}', $args); |
|
| 1219 | 1219 | |
| 1220 | 1220 | /** |
| 1221 | 1221 | * Loop through each of the tags to replace and replace both `{{tag}}` and `{{ tag }}` with the values |
| 1222 | 1222 | * @since 1.11 |
| 1223 | 1223 | */ |
| 1224 | - foreach ( $context as $tag => $value ) { |
|
| 1224 | + foreach ($context as $tag => $value) { |
|
| 1225 | 1225 | |
| 1226 | 1226 | // If the tag doesn't exist just skip it |
| 1227 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
| 1227 | + if (false === strpos($html, $open_tag.$tag.$close_tag) && false === strpos($html, $open_tag.' '.$tag.' '.$close_tag)) { |
|
| 1228 | 1228 | continue; |
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | // Array to search |
| 1232 | 1232 | $search = array( |
| 1233 | - $open_tag . $tag . $close_tag, |
|
| 1234 | - $open_tag . ' ' . $tag . ' ' . $close_tag, |
|
| 1233 | + $open_tag.$tag.$close_tag, |
|
| 1234 | + $open_tag.' '.$tag.' '.$close_tag, |
|
| 1235 | 1235 | ); |
| 1236 | 1236 | |
| 1237 | 1237 | /** |
@@ -1240,26 +1240,26 @@ discard block |
||
| 1240 | 1240 | * @param string $value The content to be shown instead of the {{tag}} placeholder |
| 1241 | 1241 | * @param array $args Arguments passed to the function |
| 1242 | 1242 | */ |
| 1243 | - $value = apply_filters( 'gravityview/field_output/context/' . $tag, $value, $args ); |
|
| 1243 | + $value = apply_filters('gravityview/field_output/context/'.$tag, $value, $args); |
|
| 1244 | 1244 | |
| 1245 | 1245 | // Finally do the replace |
| 1246 | - $html = str_replace( $search, $value, $html ); |
|
| 1246 | + $html = str_replace($search, $value, $html); |
|
| 1247 | 1247 | } |
| 1248 | 1248 | |
| 1249 | 1249 | /** |
| 1250 | 1250 | * @todo Depricate `gravityview_field_output` |
| 1251 | 1251 | */ |
| 1252 | - $html = apply_filters( 'gravityview_field_output', $html, $args ); |
|
| 1252 | + $html = apply_filters('gravityview_field_output', $html, $args); |
|
| 1253 | 1253 | |
| 1254 | 1254 | /** |
| 1255 | 1255 | * @filter `gravityview/field_output/html` Modify field HTML output |
| 1256 | 1256 | * @param string $html Existing HTML output |
| 1257 | 1257 | * @param array $args Arguments passed to the function |
| 1258 | 1258 | */ |
| 1259 | - $html = apply_filters( 'gravityview/field_output/html', $html, $args ); |
|
| 1259 | + $html = apply_filters('gravityview/field_output/html', $html, $args); |
|
| 1260 | 1260 | |
| 1261 | 1261 | // Just free up a tiny amount of memory |
| 1262 | - unset( $value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag ); |
|
| 1262 | + unset($value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag); |
|
| 1263 | 1263 | |
| 1264 | 1264 | return $html; |
| 1265 | 1265 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | /** If this file is called directly, abort. */ |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if (!defined('ABSPATH')) { |
|
| 16 | 16 | die; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -20,15 +20,15 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | function __construct() { |
| 22 | 22 | |
| 23 | - add_action( 'media_buttons', array( $this, 'add_shortcode_button'), 30); |
|
| 23 | + add_action('media_buttons', array($this, 'add_shortcode_button'), 30); |
|
| 24 | 24 | |
| 25 | - add_action( 'admin_footer', array( $this, 'add_shortcode_popup') ); |
|
| 25 | + add_action('admin_footer', array($this, 'add_shortcode_popup')); |
|
| 26 | 26 | |
| 27 | 27 | // adding styles and scripts |
| 28 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
| 28 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts_and_styles')); |
|
| 29 | 29 | |
| 30 | 30 | // ajax - populate sort fields based on the selected view |
| 31 | - add_action( 'wp_ajax_gv_sortable_fields', array( $this, 'get_sortable_fields' ) ); |
|
| 31 | + add_action('wp_ajax_gv_sortable_fields', array($this, 'get_sortable_fields')); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function is_post_editor_screen() { |
| 42 | 42 | global $current_screen, $pagenow; |
| 43 | - return !empty( $current_screen->post_type ) && 'gravityview' != $current_screen->post_type && in_array( $pagenow , array( 'post.php' , 'post-new.php' ) ); |
|
| 43 | + return !empty($current_screen->post_type) && 'gravityview' != $current_screen->post_type && in_array($pagenow, array('post.php', 'post-new.php')); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -55,15 +55,15 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * @since 1.15.3 |
| 57 | 57 | */ |
| 58 | - if( ! GVCommon::has_cap( array( 'publish_gravityviews' ) ) ) { |
|
| 58 | + if (!GVCommon::has_cap(array('publish_gravityviews'))) { |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if( !$this->is_post_editor_screen() ) { |
|
| 62 | + if (!$this->is_post_editor_screen()) { |
|
| 63 | 63 | return; |
| 64 | 64 | } |
| 65 | 65 | ?> |
| 66 | - <a href="#TB_inline?width=480&inlineId=select_gravityview_view&width=600&height=800" class="thickbox 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> |
|
| 66 | + <a href="#TB_inline?width=480&inlineId=select_gravityview_view&width=600&height=800" class="thickbox 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> |
|
| 67 | 67 | <?php |
| 68 | 68 | |
| 69 | 69 | } |
@@ -79,17 +79,17 @@ discard block |
||
| 79 | 79 | function add_shortcode_popup() { |
| 80 | 80 | global $post; |
| 81 | 81 | |
| 82 | - if( !$this->is_post_editor_screen() ) { |
|
| 82 | + if (!$this->is_post_editor_screen()) { |
|
| 83 | 83 | return; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | $post_type = get_post_type_object($post->post_type); |
| 87 | 87 | |
| 88 | - $views = get_posts( array('post_type' => 'gravityview', 'posts_per_page' => -1 ) ); |
|
| 88 | + $views = get_posts(array('post_type' => 'gravityview', 'posts_per_page' => -1)); |
|
| 89 | 89 | |
| 90 | 90 | // If there are no views set up yet, we get outta here. |
| 91 | - if( empty( $views ) ) { |
|
| 92 | - echo '<div id="select_gravityview_view"><div class="wrap">'. GravityView_Post_Types::no_views_text() .'</div></div>'; |
|
| 91 | + if (empty($views)) { |
|
| 92 | + echo '<div id="select_gravityview_view"><div class="wrap">'.GravityView_Post_Types::no_views_text().'</div></div>'; |
|
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -98,18 +98,18 @@ discard block |
||
| 98 | 98 | <form action="#" method="get" id="select_gravityview_view_form"> |
| 99 | 99 | <div class="wrap"> |
| 100 | 100 | |
| 101 | - <h2 class=""><?php esc_html_e( 'Embed a View', 'gravityview' ); ?></h2> |
|
| 102 | - <p class="subtitle"><?php printf( esc_attr ( __( 'Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview') ), $post_type->labels->singular_name, '<a href="http://gravityview.co/support/documentation/202934188/" target="_blank">', '</a>' ); ?></p> |
|
| 101 | + <h2 class=""><?php esc_html_e('Embed a View', 'gravityview'); ?></h2> |
|
| 102 | + <p class="subtitle"><?php printf(esc_attr(__('Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview')), $post_type->labels->singular_name, '<a href="http://gravityview.co/support/documentation/202934188/" target="_blank">', '</a>'); ?></p> |
|
| 103 | 103 | |
| 104 | 104 | <div> |
| 105 | - <h3><label for="gravityview_id"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label></h3> |
|
| 105 | + <h3><label for="gravityview_id"><?php esc_html_e('Select a View', 'gravityview'); ?></label></h3> |
|
| 106 | 106 | |
| 107 | 107 | <select name="gravityview_id" id="gravityview_id"> |
| 108 | - <option value=""><?php esc_html_e( '— Select a View to Insert —', 'gravityview' ); ?></option> |
|
| 108 | + <option value=""><?php esc_html_e('— Select a View to Insert —', 'gravityview'); ?></option> |
|
| 109 | 109 | <?php |
| 110 | - foreach( $views as $view ) { |
|
| 111 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
| 112 | - echo '<option value="'. $view->ID .'">'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
| 110 | + foreach ($views as $view) { |
|
| 111 | + $title = empty($view->post_title) ? __('(no title)', 'gravityview') : $view->post_title; |
|
| 112 | + echo '<option value="'.$view->ID.'">'.esc_html(sprintf('%s #%d', $title, $view->ID)).'</option>'; |
|
| 113 | 113 | } |
| 114 | 114 | ?> |
| 115 | 115 | </select> |
@@ -117,24 +117,24 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | <table class="form-table hide-if-js"> |
| 119 | 119 | |
| 120 | - <caption><?php esc_html_e( 'View Settings', 'gravityview' ); ?></caption> |
|
| 120 | + <caption><?php esc_html_e('View Settings', 'gravityview'); ?></caption> |
|
| 121 | 121 | |
| 122 | 122 | <?php |
| 123 | 123 | |
| 124 | - $settings = GravityView_View_Data::get_default_args( true ); |
|
| 124 | + $settings = GravityView_View_Data::get_default_args(true); |
|
| 125 | 125 | |
| 126 | - foreach ( $settings as $key => $setting ) { |
|
| 126 | + foreach ($settings as $key => $setting) { |
|
| 127 | 127 | |
| 128 | - if( empty( $setting['show_in_shortcode'] ) ) { continue; } |
|
| 128 | + if (empty($setting['show_in_shortcode'])) { continue; } |
|
| 129 | 129 | |
| 130 | - GravityView_Render_Settings::render_setting_row( $key, array(), NULL, 'gravityview_%s', 'gravityview_%s' ); |
|
| 130 | + GravityView_Render_Settings::render_setting_row($key, array(), NULL, 'gravityview_%s', 'gravityview_%s'); |
|
| 131 | 131 | } |
| 132 | 132 | ?> |
| 133 | 133 | |
| 134 | 134 | </table> |
| 135 | 135 | |
| 136 | 136 | <div class="submit"> |
| 137 | - <input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e('Insert View', 'gravityview' ); ?>" id="insert_gravityview_view" /> |
|
| 137 | + <input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e('Insert View', 'gravityview'); ?>" id="insert_gravityview_view" /> |
|
| 138 | 138 | <input class="button button-secondary alignright" type="submit" onclick="tb_remove(); return false;" value="<?php esc_attr_e("Cancel", 'gravityview'); ?>" /> |
| 139 | 139 | </div> |
| 140 | 140 | |
@@ -157,32 +157,32 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | function add_scripts_and_styles() { |
| 159 | 159 | |
| 160 | - if( ! $this->is_post_editor_screen() ) { |
|
| 160 | + if (!$this->is_post_editor_screen()) { |
|
| 161 | 161 | return; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - wp_enqueue_style( 'dashicons' ); |
|
| 164 | + wp_enqueue_style('dashicons'); |
|
| 165 | 165 | |
| 166 | 166 | // date picker |
| 167 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 167 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 168 | 168 | |
| 169 | 169 | $protocol = is_ssl() ? 'https://' : 'http://'; |
| 170 | 170 | |
| 171 | - wp_enqueue_style( 'jquery-ui-datepicker', $protocol.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version ); |
|
| 171 | + wp_enqueue_style('jquery-ui-datepicker', $protocol.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version); |
|
| 172 | 172 | |
| 173 | 173 | //enqueue styles |
| 174 | - wp_register_style( 'gravityview_postedit_styles', plugins_url('assets/css/admin-post-edit.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
| 175 | - wp_enqueue_style( 'gravityview_postedit_styles' ); |
|
| 174 | + wp_register_style('gravityview_postedit_styles', plugins_url('assets/css/admin-post-edit.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version); |
|
| 175 | + wp_enqueue_style('gravityview_postedit_styles'); |
|
| 176 | 176 | |
| 177 | 177 | $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
| 178 | 178 | |
| 179 | 179 | // custom js |
| 180 | - wp_register_script( 'gravityview_postedit_scripts', plugins_url('assets/js/admin-post-edit'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'jquery-ui-datepicker' ), GravityView_Plugin::version ); |
|
| 181 | - wp_enqueue_script( 'gravityview_postedit_scripts' ); |
|
| 180 | + wp_register_script('gravityview_postedit_scripts', plugins_url('assets/js/admin-post-edit'.$script_debug.'.js', GRAVITYVIEW_FILE), array('jquery', 'jquery-ui-datepicker'), GravityView_Plugin::version); |
|
| 181 | + wp_enqueue_script('gravityview_postedit_scripts'); |
|
| 182 | 182 | wp_localize_script('gravityview_postedit_scripts', 'gvGlobals', array( |
| 183 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxaddshortcode'), |
|
| 184 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
| 185 | - 'alert_1' => esc_html__( 'Please select a View', 'gravityview'), |
|
| 183 | + 'nonce' => wp_create_nonce('gravityview_ajaxaddshortcode'), |
|
| 184 | + 'loading_text' => esc_html__('Loading…', 'gravityview'), |
|
| 185 | + 'alert_1' => esc_html__('Please select a View', 'gravityview'), |
|
| 186 | 186 | )); |
| 187 | 187 | |
| 188 | 188 | } |
@@ -199,27 +199,27 @@ discard block |
||
| 199 | 199 | function get_sortable_fields() { |
| 200 | 200 | |
| 201 | 201 | // Not properly formatted request |
| 202 | - if ( empty( $_POST['viewid'] ) || !is_numeric( $_POST['viewid'] ) ) { |
|
| 203 | - exit( false ); |
|
| 202 | + if (empty($_POST['viewid']) || !is_numeric($_POST['viewid'])) { |
|
| 203 | + exit(false); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // Not valid request |
| 207 | - if( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxaddshortcode' ) ) { |
|
| 208 | - exit( false ); |
|
| 207 | + if (empty($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxaddshortcode')) { |
|
| 208 | + exit(false); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | $viewid = (int)$_POST['viewid']; |
| 212 | 212 | |
| 213 | 213 | // fetch form id assigned to the view |
| 214 | - $formid = gravityview_get_form_id( $viewid ); |
|
| 214 | + $formid = gravityview_get_form_id($viewid); |
|
| 215 | 215 | |
| 216 | 216 | // Get the default sort field for the view |
| 217 | - $sort_field = gravityview_get_template_setting( $viewid, 'sort_field' ); |
|
| 217 | + $sort_field = gravityview_get_template_setting($viewid, 'sort_field'); |
|
| 218 | 218 | |
| 219 | 219 | // Generate the output `<option>`s |
| 220 | - $response = gravityview_get_sortable_fields( $formid, $sort_field ); |
|
| 220 | + $response = gravityview_get_sortable_fields($formid, $sort_field); |
|
| 221 | 221 | |
| 222 | - exit( $response ); |
|
| 222 | + exit($response); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | } |
@@ -17,13 +17,13 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | function __construct() { |
| 19 | 19 | |
| 20 | - if( !GravityView_Compatibility::is_valid() ) { return; } |
|
| 20 | + if (!GravityView_Compatibility::is_valid()) { return; } |
|
| 21 | 21 | |
| 22 | - self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/'; |
|
| 22 | + self::$metaboxes_dir = GRAVITYVIEW_DIR.'includes/admin/metaboxes/'; |
|
| 23 | 23 | |
| 24 | - include_once self::$metaboxes_dir . 'class-gravityview-metabox-tab.php'; |
|
| 24 | + include_once self::$metaboxes_dir.'class-gravityview-metabox-tab.php'; |
|
| 25 | 25 | |
| 26 | - include_once self::$metaboxes_dir . 'class-gravityview-metabox-tabs.php'; |
|
| 26 | + include_once self::$metaboxes_dir.'class-gravityview-metabox-tabs.php'; |
|
| 27 | 27 | |
| 28 | 28 | $this->initialize(); |
| 29 | 29 | |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function initialize() { |
| 37 | 37 | |
| 38 | - add_action( 'add_meta_boxes', array( $this, 'register_metaboxes' )); |
|
| 38 | + add_action('add_meta_boxes', array($this, 'register_metaboxes')); |
|
| 39 | 39 | |
| 40 | - add_action( 'add_meta_boxes_gravityview' , array( $this, 'update_priority' ) ); |
|
| 40 | + add_action('add_meta_boxes_gravityview', array($this, 'update_priority')); |
|
| 41 | 41 | |
| 42 | 42 | // information box |
| 43 | - add_action( 'post_submitbox_misc_actions', array( $this, 'render_shortcode_hint' ) ); |
|
| 43 | + add_action('post_submitbox_misc_actions', array($this, 'render_shortcode_hint')); |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | function update_priority() { |
| 52 | 52 | global $wp_meta_boxes; |
| 53 | 53 | |
| 54 | - if( ! empty( $wp_meta_boxes['gravityview'] ) ) { |
|
| 55 | - foreach( array( 'high', 'core', 'low' ) as $position ) { |
|
| 56 | - if( isset( $wp_meta_boxes['gravityview']['normal'][ $position ] ) ) { |
|
| 57 | - foreach( $wp_meta_boxes['gravityview']['normal'][ $position ] as $key => $meta_box ) { |
|
| 58 | - if( ! preg_match( '/^gravityview_/ism', $key ) ) { |
|
| 59 | - $wp_meta_boxes['gravityview']['advanced'][ $position ][ $key ] = $meta_box; |
|
| 60 | - unset( $wp_meta_boxes['gravityview']['normal'][ $position ][ $key ] ); |
|
| 54 | + if (!empty($wp_meta_boxes['gravityview'])) { |
|
| 55 | + foreach (array('high', 'core', 'low') as $position) { |
|
| 56 | + if (isset($wp_meta_boxes['gravityview']['normal'][$position])) { |
|
| 57 | + foreach ($wp_meta_boxes['gravityview']['normal'][$position] as $key => $meta_box) { |
|
| 58 | + if (!preg_match('/^gravityview_/ism', $key)) { |
|
| 59 | + $wp_meta_boxes['gravityview']['advanced'][$position][$key] = $meta_box; |
|
| 60 | + unset($wp_meta_boxes['gravityview']['normal'][$position][$key]); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -69,23 +69,23 @@ discard block |
||
| 69 | 69 | global $post; |
| 70 | 70 | |
| 71 | 71 | // On Comment Edit, for example, $post isn't set. |
| 72 | - if( empty( $post ) || !is_object( $post ) || !isset( $post->ID ) ) { |
|
| 72 | + if (empty($post) || !is_object($post) || !isset($post->ID)) { |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // select data source for this view |
| 77 | - add_meta_box( 'gravityview_select_form', $this->get_data_source_header( $post->ID ), array( $this, 'render_data_source_metabox' ), 'gravityview', 'normal', 'high' ); |
|
| 77 | + add_meta_box('gravityview_select_form', $this->get_data_source_header($post->ID), array($this, 'render_data_source_metabox'), 'gravityview', 'normal', 'high'); |
|
| 78 | 78 | |
| 79 | 79 | // select view type/template |
| 80 | - add_meta_box( 'gravityview_select_template', __( 'Choose a View Type', 'gravityview' ), array( $this, 'render_select_template_metabox' ), 'gravityview', 'normal', 'high' ); |
|
| 80 | + add_meta_box('gravityview_select_template', __('Choose a View Type', 'gravityview'), array($this, 'render_select_template_metabox'), 'gravityview', 'normal', 'high'); |
|
| 81 | 81 | |
| 82 | 82 | // View Configuration box |
| 83 | - add_meta_box( 'gravityview_view_config', __( 'View Configuration', 'gravityview' ), array( $this, 'render_view_configuration_metabox' ), 'gravityview', 'normal', 'high' ); |
|
| 83 | + add_meta_box('gravityview_view_config', __('View Configuration', 'gravityview'), array($this, 'render_view_configuration_metabox'), 'gravityview', 'normal', 'high'); |
|
| 84 | 84 | |
| 85 | 85 | $this->add_settings_metabox_tabs(); |
| 86 | 86 | |
| 87 | 87 | // Other Settings box |
| 88 | - add_meta_box( 'gravityview_settings', __( 'View Settings', 'gravityview' ), array( $this, 'settings_metabox_render' ), 'gravityview', 'normal', 'core' ); |
|
| 88 | + add_meta_box('gravityview_settings', __('View Settings', 'gravityview'), array($this, 'settings_metabox_render'), 'gravityview', 'normal', 'core'); |
|
| 89 | 89 | |
| 90 | 90 | } |
| 91 | 91 | |
@@ -94,22 +94,22 @@ discard block |
||
| 94 | 94 | * @since 1.8 |
| 95 | 95 | * @param WP_Post $post |
| 96 | 96 | */ |
| 97 | - function settings_metabox_render( $post ) { |
|
| 97 | + function settings_metabox_render($post) { |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * @param WP_Post $post |
| 101 | 101 | */ |
| 102 | - do_action( 'gravityview/metaboxes/before_render', $post ); |
|
| 102 | + do_action('gravityview/metaboxes/before_render', $post); |
|
| 103 | 103 | |
| 104 | 104 | $metaboxes = GravityView_Metabox_Tabs::get_all(); |
| 105 | 105 | |
| 106 | - include self::$metaboxes_dir . 'views/gravityview-navigation.php'; |
|
| 107 | - include self::$metaboxes_dir . 'views/gravityview-content.php'; |
|
| 106 | + include self::$metaboxes_dir.'views/gravityview-navigation.php'; |
|
| 107 | + include self::$metaboxes_dir.'views/gravityview-content.php'; |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * @param WP_Post $post |
| 111 | 111 | */ |
| 112 | - do_action( 'gravityview/metaboxes/after_render', $post ); |
|
| 112 | + do_action('gravityview/metaboxes/after_render', $post); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $metaboxes = array( |
| 122 | 122 | array( |
| 123 | 123 | 'id' => 'template_settings', |
| 124 | - 'title' => __( 'View Settings', 'gravityview' ), |
|
| 124 | + 'title' => __('View Settings', 'gravityview'), |
|
| 125 | 125 | 'file' => 'view-settings.php', |
| 126 | 126 | 'icon-class' => 'dashicons-admin-generic', |
| 127 | 127 | 'callback' => '', |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | ), |
| 130 | 130 | array( |
| 131 | 131 | 'id' => 'single_entry', // Use the same ID as View Settings for backward compatibility |
| 132 | - 'title' => __( 'Single Entry', 'gravityview' ), |
|
| 132 | + 'title' => __('Single Entry', 'gravityview'), |
|
| 133 | 133 | 'file' => 'single-entry.php', |
| 134 | 134 | 'icon-class' => 'dashicons-media-default', |
| 135 | 135 | 'callback' => '', |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | ), |
| 138 | 138 | array( |
| 139 | 139 | 'id' => 'sort_filter', |
| 140 | - 'title' => __( 'Filter & Sort', 'gravityview' ), |
|
| 140 | + 'title' => __('Filter & Sort', 'gravityview'), |
|
| 141 | 141 | 'file' => 'sort-filter.php', |
| 142 | 142 | 'icon-class' => 'dashicons-sort', |
| 143 | 143 | 'callback' => '', |
@@ -150,17 +150,17 @@ discard block |
||
| 150 | 150 | * @param array $metaboxes |
| 151 | 151 | * @since 1.8 |
| 152 | 152 | */ |
| 153 | - $metaboxes = apply_filters( 'gravityview/metaboxes/default', $metaboxes ); |
|
| 153 | + $metaboxes = apply_filters('gravityview/metaboxes/default', $metaboxes); |
|
| 154 | 154 | |
| 155 | - foreach( $metaboxes as $m ) { |
|
| 155 | + foreach ($metaboxes as $m) { |
|
| 156 | 156 | |
| 157 | - $tab = new GravityView_Metabox_Tab( $m['id'], $m['title'], $m['file'], $m['icon-class'], $m['callback'], $m['callback_args'] ); |
|
| 157 | + $tab = new GravityView_Metabox_Tab($m['id'], $m['title'], $m['file'], $m['icon-class'], $m['callback'], $m['callback_args']); |
|
| 158 | 158 | |
| 159 | - GravityView_Metabox_Tabs::add( $tab ); |
|
| 159 | + GravityView_Metabox_Tabs::add($tab); |
|
| 160 | 160 | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - unset( $tab ); |
|
| 163 | + unset($tab); |
|
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | |
@@ -173,18 +173,18 @@ discard block |
||
| 173 | 173 | * |
| 174 | 174 | * @return string "Data Source", plus links if any |
| 175 | 175 | */ |
| 176 | - private function get_data_source_header( $post_id ) { |
|
| 176 | + private function get_data_source_header($post_id) { |
|
| 177 | 177 | |
| 178 | 178 | //current value |
| 179 | - $current_form = gravityview_get_form_id( $post_id ); |
|
| 179 | + $current_form = gravityview_get_form_id($post_id); |
|
| 180 | 180 | |
| 181 | - $links = GravityView_Admin_Views::get_connected_form_links( $current_form, false ); |
|
| 181 | + $links = GravityView_Admin_Views::get_connected_form_links($current_form, false); |
|
| 182 | 182 | |
| 183 | - if( !empty( $links ) ) { |
|
| 184 | - $links = '<span class="alignright gv-form-links">'. $links .'</span>'; |
|
| 183 | + if (!empty($links)) { |
|
| 184 | + $links = '<span class="alignright gv-form-links">'.$links.'</span>'; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - return __( 'Data Source', 'gravityview' ) . $links; |
|
| 187 | + return __('Data Source', 'gravityview').$links; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -194,9 +194,9 @@ discard block |
||
| 194 | 194 | * @param object $post |
| 195 | 195 | * @return void |
| 196 | 196 | */ |
| 197 | - function render_data_source_metabox( $post ) { |
|
| 197 | + function render_data_source_metabox($post) { |
|
| 198 | 198 | |
| 199 | - include self::$metaboxes_dir . 'views/data-source.php'; |
|
| 199 | + include self::$metaboxes_dir.'views/data-source.php'; |
|
| 200 | 200 | |
| 201 | 201 | } |
| 202 | 202 | |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | * @param object $post |
| 208 | 208 | * @return void |
| 209 | 209 | */ |
| 210 | - function render_select_template_metabox( $post ) { |
|
| 210 | + function render_select_template_metabox($post) { |
|
| 211 | 211 | |
| 212 | - include self::$metaboxes_dir . 'views/select-template.php'; |
|
| 212 | + include self::$metaboxes_dir.'views/select-template.php'; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -218,18 +218,18 @@ discard block |
||
| 218 | 218 | * @param mixed $curr_form Form ID |
| 219 | 219 | * @return null|string Merge tags html; NULL if $curr_form isn't defined. |
| 220 | 220 | */ |
| 221 | - public static function render_merge_tags_scripts( $curr_form ) { |
|
| 221 | + public static function render_merge_tags_scripts($curr_form) { |
|
| 222 | 222 | |
| 223 | - if( empty( $curr_form )) { |
|
| 223 | + if (empty($curr_form)) { |
|
| 224 | 224 | return NULL; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $form = gravityview_get_form( $curr_form ); |
|
| 227 | + $form = gravityview_get_form($curr_form); |
|
| 228 | 228 | |
| 229 | 229 | $get_id_backup = isset($_GET['id']) ? $_GET['id'] : NULL; |
| 230 | 230 | |
| 231 | - if( isset( $form['id'] ) ) { |
|
| 232 | - $form_script = 'var form = ' . GFCommon::json_encode($form) . ';'; |
|
| 231 | + if (isset($form['id'])) { |
|
| 232 | + $form_script = 'var form = '.GFCommon::json_encode($form).';'; |
|
| 233 | 233 | |
| 234 | 234 | // The `gf_vars()` method needs a $_GET[id] variable set with the form ID. |
| 235 | 235 | $_GET['id'] = $form['id']; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $form_script = 'var form = new Form();'; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - $output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars(false) . '</script>'; |
|
| 241 | + $output = '<script type="text/javascript" data-gv-merge-tags="1">'.$form_script."\n".GFCommon::gf_vars(false).'</script>'; |
|
| 242 | 242 | |
| 243 | 243 | // Restore previous $_GET setting |
| 244 | 244 | $_GET['id'] = $get_id_backup; |
@@ -253,20 +253,20 @@ discard block |
||
| 253 | 253 | * @param mixed $post |
| 254 | 254 | * @return void |
| 255 | 255 | */ |
| 256 | - function render_view_configuration_metabox( $post ) { |
|
| 256 | + function render_view_configuration_metabox($post) { |
|
| 257 | 257 | |
| 258 | 258 | // Use nonce for verification |
| 259 | - wp_nonce_field( 'gravityview_view_configuration', 'gravityview_view_configuration_nonce' ); |
|
| 259 | + wp_nonce_field('gravityview_view_configuration', 'gravityview_view_configuration_nonce'); |
|
| 260 | 260 | |
| 261 | 261 | // Selected Form |
| 262 | - $curr_form = gravityview_get_form_id( $post->ID ); |
|
| 262 | + $curr_form = gravityview_get_form_id($post->ID); |
|
| 263 | 263 | |
| 264 | 264 | // Selected template |
| 265 | - $curr_template = gravityview_get_template_id( $post->ID ); |
|
| 265 | + $curr_template = gravityview_get_template_id($post->ID); |
|
| 266 | 266 | |
| 267 | - echo self::render_merge_tags_scripts( $curr_form ); |
|
| 267 | + echo self::render_merge_tags_scripts($curr_form); |
|
| 268 | 268 | |
| 269 | - include self::$metaboxes_dir . 'views/view-configuration.php'; |
|
| 269 | + include self::$metaboxes_dir.'views/view-configuration.php'; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -276,12 +276,12 @@ discard block |
||
| 276 | 276 | * @param object $post |
| 277 | 277 | * @return void |
| 278 | 278 | */ |
| 279 | - function render_view_settings_metabox( $post ) { |
|
| 279 | + function render_view_settings_metabox($post) { |
|
| 280 | 280 | |
| 281 | 281 | // View template settings |
| 282 | - $current_settings = gravityview_get_template_settings( $post->ID ); |
|
| 282 | + $current_settings = gravityview_get_template_settings($post->ID); |
|
| 283 | 283 | |
| 284 | - include self::$metaboxes_dir . 'views/view-settings.php'; |
|
| 284 | + include self::$metaboxes_dir.'views/view-settings.php'; |
|
| 285 | 285 | |
| 286 | 286 | } |
| 287 | 287 | |
@@ -298,12 +298,12 @@ discard block |
||
| 298 | 298 | global $post; |
| 299 | 299 | |
| 300 | 300 | // Only show this on GravityView post types. |
| 301 | - if( false === gravityview_is_admin_page() ) { return; } |
|
| 301 | + if (false === gravityview_is_admin_page()) { return; } |
|
| 302 | 302 | |
| 303 | 303 | // If the View hasn't been configured yet, don't show embed shortcode |
| 304 | - if( !gravityview_get_directory_fields( $post->ID ) ) { return; } |
|
| 304 | + if (!gravityview_get_directory_fields($post->ID)) { return; } |
|
| 305 | 305 | |
| 306 | - include self::$metaboxes_dir . 'views/shortcode-hint.php'; |
|
| 306 | + include self::$metaboxes_dir.'views/shortcode-hint.php'; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | } |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | * @param array $callback_args Arguments passed to the callback |
| 98 | 98 | * @return void |
| 99 | 99 | */ |
| 100 | - function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array() ) { |
|
| 100 | + function __construct($id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array()) { |
|
| 101 | 101 | |
| 102 | 102 | $this->id = $this->prefix.$id; |
| 103 | 103 | $this->title = $title; |
| 104 | 104 | $this->render_template_file = $file; |
| 105 | 105 | $this->callback = $callback; |
| 106 | 106 | $this->callback_args = $callback_args; |
| 107 | - $this->icon_class_name = $this->parse_icon_class_name( $icon_class_name ); |
|
| 107 | + $this->icon_class_name = $this->parse_icon_class_name($icon_class_name); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @return string sanitized CSS class |
| 118 | 118 | */ |
| 119 | - function parse_icon_class_name( $icon_class_name = '' ) { |
|
| 119 | + function parse_icon_class_name($icon_class_name = '') { |
|
| 120 | 120 | |
| 121 | - if( preg_match( '/dashicon/i', $icon_class_name ) ) { |
|
| 122 | - $icon_class_name = 'dashicons ' . $icon_class_name; |
|
| 121 | + if (preg_match('/dashicon/i', $icon_class_name)) { |
|
| 122 | + $icon_class_name = 'dashicons '.$icon_class_name; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - return esc_attr( $icon_class_name ); |
|
| 125 | + return esc_attr($icon_class_name); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -140,38 +140,38 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @param WP_Post $post Currently edited post object |
| 142 | 142 | */ |
| 143 | - function render( $post ) { |
|
| 143 | + function render($post) { |
|
| 144 | 144 | |
| 145 | - if( !empty( $this->render_template_file ) ) { |
|
| 145 | + if (!empty($this->render_template_file)) { |
|
| 146 | 146 | |
| 147 | 147 | $file = $this->render_template_file; |
| 148 | 148 | |
| 149 | 149 | // If the full path exists, use it |
| 150 | - if( file_exists( $file ) ) { |
|
| 150 | + if (file_exists($file)) { |
|
| 151 | 151 | $path = $file; |
| 152 | 152 | } else { |
| 153 | - $path = GRAVITYVIEW_DIR .'includes/admin/metaboxes/views/'.$file; |
|
| 153 | + $path = GRAVITYVIEW_DIR.'includes/admin/metaboxes/views/'.$file; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if( file_exists( $path ) ) { |
|
| 156 | + if (file_exists($path)) { |
|
| 157 | 157 | include $path; |
| 158 | 158 | } else { |
| 159 | - do_action( 'gravityview_log_error', 'Metabox template file not found', $this ); |
|
| 159 | + do_action('gravityview_log_error', 'Metabox template file not found', $this); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - } else if( !empty( $this->callback ) ) { |
|
| 162 | + } else if (!empty($this->callback)) { |
|
| 163 | 163 | |
| 164 | - if( is_callable( $this->callback ) ) { |
|
| 164 | + if (is_callable($this->callback)) { |
|
| 165 | 165 | |
| 166 | 166 | /** @see do_accordion_sections() */ |
| 167 | - call_user_func( $this->callback, $post, (array) $this ); |
|
| 167 | + call_user_func($this->callback, $post, (array)$this); |
|
| 168 | 168 | |
| 169 | 169 | } else { |
| 170 | - do_action( 'gravityview_log_error', 'Metabox callback was not callable', $this ); |
|
| 170 | + do_action('gravityview_log_error', 'Metabox callback was not callable', $this); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | } else { |
| 174 | - do_action( 'gravityview_log_error', 'Metabox file and callback were not found', $this ); |
|
| 174 | + do_action('gravityview_log_error', 'Metabox file and callback were not found', $this); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
@@ -23,53 +23,53 @@ discard block |
||
| 23 | 23 | * @param string $input_type (textarea, list, select, etc.) |
| 24 | 24 | * @return array Array of field options with `label`, `value`, `type`, `default` keys |
| 25 | 25 | */ |
| 26 | - public static function get_default_field_options( $field_type, $template_id, $field_id, $context, $input_type ) { |
|
| 26 | + public static function get_default_field_options($field_type, $template_id, $field_id, $context, $input_type) { |
|
| 27 | 27 | |
| 28 | 28 | $field_options = array(); |
| 29 | 29 | |
| 30 | - if( 'field' === $field_type ) { |
|
| 30 | + if ('field' === $field_type) { |
|
| 31 | 31 | |
| 32 | 32 | // Default options - fields |
| 33 | 33 | $field_options = array( |
| 34 | 34 | 'show_label' => array( |
| 35 | 35 | 'type' => 'checkbox', |
| 36 | - 'label' => __( 'Show Label', 'gravityview' ), |
|
| 36 | + 'label' => __('Show Label', 'gravityview'), |
|
| 37 | 37 | 'value' => true, |
| 38 | 38 | ), |
| 39 | 39 | 'custom_label' => array( |
| 40 | 40 | 'type' => 'text', |
| 41 | - 'label' => __( 'Custom Label:', 'gravityview' ), |
|
| 41 | + 'label' => __('Custom Label:', 'gravityview'), |
|
| 42 | 42 | 'value' => '', |
| 43 | 43 | 'merge_tags' => true, |
| 44 | 44 | ), |
| 45 | 45 | 'custom_class' => array( |
| 46 | 46 | 'type' => 'text', |
| 47 | - 'label' => __( 'Custom CSS Class:', 'gravityview' ), |
|
| 48 | - 'desc' => __( 'This class will be added to the field container', 'gravityview'), |
|
| 47 | + 'label' => __('Custom CSS Class:', 'gravityview'), |
|
| 48 | + 'desc' => __('This class will be added to the field container', 'gravityview'), |
|
| 49 | 49 | 'value' => '', |
| 50 | 50 | 'merge_tags' => true, |
| 51 | 51 | 'tooltip' => 'gv_css_merge_tags', |
| 52 | 52 | ), |
| 53 | 53 | 'only_loggedin' => array( |
| 54 | 54 | 'type' => 'checkbox', |
| 55 | - 'label' => __( 'Make visible only to logged-in users?', 'gravityview' ), |
|
| 55 | + 'label' => __('Make visible only to logged-in users?', 'gravityview'), |
|
| 56 | 56 | 'value' => '' |
| 57 | 57 | ), |
| 58 | 58 | 'only_loggedin_cap' => array( |
| 59 | 59 | 'type' => 'select', |
| 60 | - 'label' => __( 'Make visible for:', 'gravityview' ), |
|
| 61 | - 'options' => self::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
|
| 60 | + 'label' => __('Make visible for:', 'gravityview'), |
|
| 61 | + 'options' => self::get_cap_choices($template_id, $field_id, $context, $input_type), |
|
| 62 | 62 | 'class' => 'widefat', |
| 63 | 63 | 'value' => 'read', |
| 64 | 64 | ), |
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | 67 | // Match Table as well as DataTables |
| 68 | - if( preg_match( '/table/ism', $template_id ) && 'single' !== $context ) { |
|
| 68 | + if (preg_match('/table/ism', $template_id) && 'single' !== $context) { |
|
| 69 | 69 | $field_options['width'] = array( |
| 70 | 70 | 'type' => 'number', |
| 71 | 71 | 'label' => __('Percent Width', 'gravityview'), |
| 72 | - 'desc' => __( 'Leave blank for column width to be based on the field content.', 'gravityview'), |
|
| 72 | + 'desc' => __('Leave blank for column width to be based on the field content.', 'gravityview'), |
|
| 73 | 73 | 'class' => 'code widefat', |
| 74 | 74 | 'value' => '', |
| 75 | 75 | ); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @param[in] string $context What context are we in? Example: `single` or `directory` |
| 86 | 86 | * @param[in] string $input_type (textarea, list, select, etc.) |
| 87 | 87 | */ |
| 88 | - $field_options = apply_filters( "gravityview_template_{$field_type}_options", $field_options, $template_id, $field_id, $context, $input_type ); |
|
| 88 | + $field_options = apply_filters("gravityview_template_{$field_type}_options", $field_options, $template_id, $field_id, $context, $input_type); |
|
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * @filter `gravityview_template_{$input_type}_options` Filter the field options by input type (`$input_type` examples: `textarea`, `list`, `select`, etc.) |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param[in] string $context What context are we in? Example: `single` or `directory` |
| 96 | 96 | * @param[in] string $input_type (textarea, list, select, etc.) |
| 97 | 97 | */ |
| 98 | - $field_options = apply_filters( "gravityview_template_{$input_type}_options", $field_options, $template_id, $field_id, $context, $input_type ); |
|
| 98 | + $field_options = apply_filters("gravityview_template_{$input_type}_options", $field_options, $template_id, $field_id, $context, $input_type); |
|
| 99 | 99 | |
| 100 | 100 | return $field_options; |
| 101 | 101 | } |
@@ -111,19 +111,19 @@ discard block |
||
| 111 | 111 | * @param string $input_type Optional. (textarea, list, select, etc.) |
| 112 | 112 | * @return array Associative array, with the key being the capability and the value being the label shown. |
| 113 | 113 | */ |
| 114 | - static public function get_cap_choices( $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
|
| 114 | + static public function get_cap_choices($template_id = '', $field_id = '', $context = '', $input_type = '') { |
|
| 115 | 115 | |
| 116 | 116 | $select_cap_choices = array( |
| 117 | - 'read' => __( 'Any Logged-In User', 'gravityview' ), |
|
| 118 | - 'publish_posts' => __( 'Author Or Higher', 'gravityview' ), |
|
| 119 | - 'gravityforms_view_entries' => __( 'Can View Gravity Forms Entries', 'gravityview' ), |
|
| 120 | - 'delete_others_posts' => __( 'Editor Or Higher', 'gravityview' ), |
|
| 121 | - 'gravityforms_edit_entries' => __( 'Can Edit Gravity Forms Entries', 'gravityview' ), |
|
| 122 | - 'manage_options' => __( 'Administrator', 'gravityview' ), |
|
| 117 | + 'read' => __('Any Logged-In User', 'gravityview'), |
|
| 118 | + 'publish_posts' => __('Author Or Higher', 'gravityview'), |
|
| 119 | + 'gravityforms_view_entries' => __('Can View Gravity Forms Entries', 'gravityview'), |
|
| 120 | + 'delete_others_posts' => __('Editor Or Higher', 'gravityview'), |
|
| 121 | + 'gravityforms_edit_entries' => __('Can Edit Gravity Forms Entries', 'gravityview'), |
|
| 122 | + 'manage_options' => __('Administrator', 'gravityview'), |
|
| 123 | 123 | ); |
| 124 | 124 | |
| 125 | - if( is_multisite() ) { |
|
| 126 | - $select_cap_choices['manage_network'] = __('Multisite Super Admin', 'gravityview' ); |
|
| 125 | + if (is_multisite()) { |
|
| 126 | + $select_cap_choices['manage_network'] = __('Multisite Super Admin', 'gravityview'); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @param string $context Optional. What context are we in? Example: `single` or `directory` |
| 137 | 137 | * @param string $input_type Optional. (textarea, list, select, etc.) |
| 138 | 138 | */ |
| 139 | - $select_cap_choices = apply_filters('gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type ); |
|
| 139 | + $select_cap_choices = apply_filters('gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type); |
|
| 140 | 140 | |
| 141 | 141 | return $select_cap_choices; |
| 142 | 142 | } |
@@ -161,26 +161,26 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @return string HTML of dialog box |
| 163 | 163 | */ |
| 164 | - public static function render_field_options( $field_type, $template_id, $field_id, $field_label, $area, $input_type = NULL, $uniqid = '', $current = '', $context = 'single', $item = array() ) { |
|
| 164 | + public static function render_field_options($field_type, $template_id, $field_id, $field_label, $area, $input_type = NULL, $uniqid = '', $current = '', $context = 'single', $item = array()) { |
|
| 165 | 165 | |
| 166 | - if( empty( $uniqid ) ) { |
|
| 166 | + if (empty($uniqid)) { |
|
| 167 | 167 | //generate a unique field id |
| 168 | 168 | $uniqid = uniqid('', false); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // get field/widget options |
| 172 | - $options = self::get_default_field_options( $field_type, $template_id, $field_id, $context, $input_type ); |
|
| 172 | + $options = self::get_default_field_options($field_type, $template_id, $field_id, $context, $input_type); |
|
| 173 | 173 | |
| 174 | 174 | // two different post arrays, depending of the field type |
| 175 | - $name_prefix = $field_type .'s' .'['. $area .']['. $uniqid .']'; |
|
| 175 | + $name_prefix = $field_type.'s'.'['.$area.']['.$uniqid.']'; |
|
| 176 | 176 | |
| 177 | 177 | // build output |
| 178 | 178 | $output = ''; |
| 179 | - $output .= '<input type="hidden" class="field-key" name="'. $name_prefix .'[id]" value="'. esc_attr( $field_id ) .'">'; |
|
| 180 | - $output .= '<input type="hidden" class="field-label" name="'. $name_prefix .'[label]" value="'. esc_attr( $field_label ) .'">'; |
|
| 179 | + $output .= '<input type="hidden" class="field-key" name="'.$name_prefix.'[id]" value="'.esc_attr($field_id).'">'; |
|
| 180 | + $output .= '<input type="hidden" class="field-label" name="'.$name_prefix.'[label]" value="'.esc_attr($field_label).'">'; |
|
| 181 | 181 | |
| 182 | 182 | // If there are no options, return what we got. |
| 183 | - if(empty($options)) { |
|
| 183 | + if (empty($options)) { |
|
| 184 | 184 | |
| 185 | 185 | // This is here for checking if the output is empty in render_label() |
| 186 | 186 | $output .= '<!-- No Options -->'; |
@@ -188,33 +188,33 @@ discard block |
||
| 188 | 188 | return $output; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - $output .= '<div class="gv-dialog-options" title="'. esc_attr( sprintf( __( 'Options: %s', 'gravityview' ) , strip_tags( html_entity_decode( $field_label ) ) ) ) .'">'; |
|
| 191 | + $output .= '<div class="gv-dialog-options" title="'.esc_attr(sprintf(__('Options: %s', 'gravityview'), strip_tags(html_entity_decode($field_label)))).'">'; |
|
| 192 | 192 | |
| 193 | 193 | /** |
| 194 | 194 | * @since 1.8 |
| 195 | 195 | */ |
| 196 | - if( !empty( $item['subtitle'] ) ) { |
|
| 197 | - $output .= '<div class="subtitle">' . $item['subtitle'] . '</div>'; |
|
| 196 | + if (!empty($item['subtitle'])) { |
|
| 197 | + $output .= '<div class="subtitle">'.$item['subtitle'].'</div>'; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - foreach( $options as $key => $option ) { |
|
| 200 | + foreach ($options as $key => $option) { |
|
| 201 | 201 | |
| 202 | - $value = isset( $current[ $key ] ) ? $current[ $key ] : NULL; |
|
| 202 | + $value = isset($current[$key]) ? $current[$key] : NULL; |
|
| 203 | 203 | |
| 204 | - $field_output = self::render_field_option( $name_prefix . '['. $key .']' , $option, $value); |
|
| 204 | + $field_output = self::render_field_option($name_prefix.'['.$key.']', $option, $value); |
|
| 205 | 205 | |
| 206 | 206 | // The setting is empty |
| 207 | - if( empty( $field_output ) ) { |
|
| 207 | + if (empty($field_output)) { |
|
| 208 | 208 | continue; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - switch( $option['type'] ) { |
|
| 211 | + switch ($option['type']) { |
|
| 212 | 212 | // Hide hidden fields |
| 213 | 213 | case 'hidden': |
| 214 | - $output .= '<div class="gv-setting-container gv-setting-container-'. esc_attr( $key ) . ' screen-reader-text">'. $field_output . '</div>'; |
|
| 214 | + $output .= '<div class="gv-setting-container gv-setting-container-'.esc_attr($key).' screen-reader-text">'.$field_output.'</div>'; |
|
| 215 | 215 | break; |
| 216 | 216 | default: |
| 217 | - $output .= '<div class="gv-setting-container gv-setting-container-'. esc_attr( $key ) . '">'. $field_output .'</div>'; |
|
| 217 | + $output .= '<div class="gv-setting-container gv-setting-container-'.esc_attr($key).'">'.$field_output.'</div>'; |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param mixed $curr_value Current value of option |
| 236 | 236 | * @return string HTML output of option |
| 237 | 237 | */ |
| 238 | - public static function render_field_option( $name = '', $option, $curr_value = NULL ) { |
|
| 238 | + public static function render_field_option($name = '', $option, $curr_value = NULL) { |
|
| 239 | 239 | |
| 240 | 240 | $output = ''; |
| 241 | 241 | |
@@ -243,19 +243,19 @@ discard block |
||
| 243 | 243 | * @deprecated setting index 'default' was replaced by 'value' |
| 244 | 244 | * @see GravityView_FieldType::get_field_defaults |
| 245 | 245 | */ |
| 246 | - if( !empty( $option['default'] ) && empty( $option['value'] ) ) { |
|
| 246 | + if (!empty($option['default']) && empty($option['value'])) { |
|
| 247 | 247 | $option['value'] = $option['default']; |
| 248 | - _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting '. $name .' details' ); |
|
| 248 | + _deprecated_function('GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting '.$name.' details'); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // prepare to render option field type |
| 252 | - if( isset( $option['type'] ) ) { |
|
| 252 | + if (isset($option['type'])) { |
|
| 253 | 253 | |
| 254 | - $type_class = self::load_type_class( $option ); |
|
| 254 | + $type_class = self::load_type_class($option); |
|
| 255 | 255 | |
| 256 | - if( class_exists( $type_class ) ) { |
|
| 256 | + if (class_exists($type_class)) { |
|
| 257 | 257 | |
| 258 | - $render_type = new $type_class( $name, $option, $curr_value ); |
|
| 258 | + $render_type = new $type_class($name, $option, $curr_value); |
|
| 259 | 259 | |
| 260 | 260 | ob_start(); |
| 261 | 261 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * @param[in,out] string $output field class name |
| 270 | 270 | * @param[in] array $option option field data |
| 271 | 271 | */ |
| 272 | - $output = apply_filters( "gravityview/option/output/{$option['type']}" , $output, $option ); |
|
| 272 | + $output = apply_filters("gravityview/option/output/{$option['type']}", $output, $option); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | } // isset option[type] |
@@ -291,35 +291,35 @@ discard block |
||
| 291 | 291 | * @param string $id [description] |
| 292 | 292 | * @return void [description] |
| 293 | 293 | */ |
| 294 | - public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) { |
|
| 294 | + public static function render_setting_row($key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s') { |
|
| 295 | 295 | |
| 296 | - $setting = GravityView_View_Data::get_default_arg( $key, true ); |
|
| 296 | + $setting = GravityView_View_Data::get_default_arg($key, true); |
|
| 297 | 297 | |
| 298 | 298 | // If the key doesn't exist, there's something wrong. |
| 299 | - if( empty( $setting ) ) { return; } |
|
| 299 | + if (empty($setting)) { return; } |
|
| 300 | 300 | |
| 301 | 301 | /** |
| 302 | 302 | * @deprecated setting index 'name' was replaced by 'label' |
| 303 | 303 | * @see GravityView_FieldType::get_field_defaults |
| 304 | 304 | */ |
| 305 | - if( isset( $setting['name'] ) && empty( $setting['label'] ) ) { |
|
| 305 | + if (isset($setting['name']) && empty($setting['label'])) { |
|
| 306 | 306 | $setting['label'] = $setting['name']; |
| 307 | - _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting '. $key .' details' ); |
|
| 307 | + _deprecated_function('GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting '.$key.' details'); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - $name = esc_attr( sprintf( $name, $key ) ); |
|
| 311 | - $setting['id'] = esc_attr( sprintf( $id, $key ) ); |
|
| 312 | - $setting['tooltip'] = 'gv_' . $key; |
|
| 310 | + $name = esc_attr(sprintf($name, $key)); |
|
| 311 | + $setting['id'] = esc_attr(sprintf($id, $key)); |
|
| 312 | + $setting['tooltip'] = 'gv_'.$key; |
|
| 313 | 313 | |
| 314 | 314 | // Use default if current setting isn't set. |
| 315 | - $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting['value']; |
|
| 315 | + $curr_value = isset($current_settings[$key]) ? $current_settings[$key] : $setting['value']; |
|
| 316 | 316 | |
| 317 | 317 | // default setting type = text |
| 318 | - $setting['type'] = empty( $setting['type'] ) ? 'text' : $setting['type']; |
|
| 318 | + $setting['type'] = empty($setting['type']) ? 'text' : $setting['type']; |
|
| 319 | 319 | |
| 320 | 320 | // merge tags |
| 321 | - if( !isset( $setting['merge_tags'] ) ) { |
|
| 322 | - if( $setting['type'] === 'text' ) { |
|
| 321 | + if (!isset($setting['merge_tags'])) { |
|
| 322 | + if ($setting['type'] === 'text') { |
|
| 323 | 323 | $setting['merge_tags'] = true; |
| 324 | 324 | } else { |
| 325 | 325 | $setting['merge_tags'] = false; |
@@ -329,27 +329,27 @@ discard block |
||
| 329 | 329 | $output = ''; |
| 330 | 330 | |
| 331 | 331 | // render the setting |
| 332 | - $type_class = self::load_type_class( $setting ); |
|
| 333 | - if( class_exists( $type_class ) ) { |
|
| 332 | + $type_class = self::load_type_class($setting); |
|
| 333 | + if (class_exists($type_class)) { |
|
| 334 | 334 | /** @var GravityView_FieldType $render_type */ |
| 335 | - $render_type = new $type_class( $name, $setting, $curr_value ); |
|
| 335 | + $render_type = new $type_class($name, $setting, $curr_value); |
|
| 336 | 336 | ob_start(); |
| 337 | - $render_type->render_setting( $override_input ); |
|
| 337 | + $render_type->render_setting($override_input); |
|
| 338 | 338 | $output = ob_get_clean(); |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // Check if setting is specific for a template |
| 342 | - if( !empty( $setting['show_in_template'] ) ) { |
|
| 343 | - if( !is_array( $setting['show_in_template'] ) ) { |
|
| 344 | - $setting['show_in_template'] = array( $setting['show_in_template'] ); |
|
| 342 | + if (!empty($setting['show_in_template'])) { |
|
| 343 | + if (!is_array($setting['show_in_template'])) { |
|
| 344 | + $setting['show_in_template'] = array($setting['show_in_template']); |
|
| 345 | 345 | } |
| 346 | - $show_if = ' data-show-if="'. implode( ' ', $setting['show_in_template'] ).'"'; |
|
| 346 | + $show_if = ' data-show-if="'.implode(' ', $setting['show_in_template']).'"'; |
|
| 347 | 347 | } else { |
| 348 | 348 | $show_if = ''; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // output |
| 352 | - echo '<tr valign="top" '. $show_if .'>' . $output . '</tr>'; |
|
| 352 | + echo '<tr valign="top" '.$show_if.'>'.$output.'</tr>'; |
|
| 353 | 353 | |
| 354 | 354 | } |
| 355 | 355 | |
@@ -359,9 +359,9 @@ discard block |
||
| 359 | 359 | * @param array $field |
| 360 | 360 | * @return string type class name |
| 361 | 361 | */ |
| 362 | - public static function load_type_class( $field = NULL ) { |
|
| 362 | + public static function load_type_class($field = NULL) { |
|
| 363 | 363 | |
| 364 | - if( empty( $field['type'] ) ) { |
|
| 364 | + if (empty($field['type'])) { |
|
| 365 | 365 | return NULL; |
| 366 | 366 | } |
| 367 | 367 | |
@@ -370,20 +370,20 @@ discard block |
||
| 370 | 370 | * @param string $class_suffix field class suffix; `GravityView_FieldType_{$class_suffix}` |
| 371 | 371 | * @param array $field field data |
| 372 | 372 | */ |
| 373 | - $type_class = apply_filters( "gravityview/setting/class/{$field['type']}", 'GravityView_FieldType_' . $field['type'], $field ); |
|
| 373 | + $type_class = apply_filters("gravityview/setting/class/{$field['type']}", 'GravityView_FieldType_'.$field['type'], $field); |
|
| 374 | 374 | |
| 375 | - if( !class_exists( $type_class ) ) { |
|
| 375 | + if (!class_exists($type_class)) { |
|
| 376 | 376 | |
| 377 | 377 | /** |
| 378 | 378 | * @filter `gravityview/setting/class_file/{field_type}` |
| 379 | 379 | * @param string $field_type_include_path field class file path |
| 380 | 380 | * @param array $field field data |
| 381 | 381 | */ |
| 382 | - $class_file = apply_filters( "gravityview/setting/class_file/{$field['type']}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field['type']}.php", $field ); |
|
| 382 | + $class_file = apply_filters("gravityview/setting/class_file/{$field['type']}", GRAVITYVIEW_DIR."includes/admin/field-types/type_{$field['type']}.php", $field); |
|
| 383 | 383 | |
| 384 | - if( $class_file ) { |
|
| 385 | - if( file_exists( $class_file ) ) { |
|
| 386 | - require_once( $class_file ); |
|
| 384 | + if ($class_file) { |
|
| 385 | + if (file_exists($class_file)) { |
|
| 386 | + require_once($class_file); |
|
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | 389 | |
@@ -403,10 +403,10 @@ discard block |
||
| 403 | 403 | * @param string $current current value |
| 404 | 404 | * @return string html tags |
| 405 | 405 | */ |
| 406 | - public static function render_checkbox_option( $name = '', $id = '', $current = '' ) { |
|
| 406 | + public static function render_checkbox_option($name = '', $id = '', $current = '') { |
|
| 407 | 407 | |
| 408 | - $output = '<input name="'. esc_attr( $name ) .'" type="hidden" value="0">'; |
|
| 409 | - $output .= '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="checkbox" value="1" '. checked( $current, '1', false ) .' >'; |
|
| 408 | + $output = '<input name="'.esc_attr($name).'" type="hidden" value="0">'; |
|
| 409 | + $output .= '<input name="'.esc_attr($name).'" id="'.esc_attr($id).'" type="checkbox" value="1" '.checked($current, '1', false).' >'; |
|
| 410 | 410 | |
| 411 | 411 | return $output; |
| 412 | 412 | } |
@@ -421,25 +421,25 @@ discard block |
||
| 421 | 421 | * @param array $args Field settings, including `class` key for CSS class |
| 422 | 422 | * @return string [html tags] |
| 423 | 423 | */ |
| 424 | - public static function render_text_option( $name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array() ) { |
|
| 424 | + public static function render_text_option($name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array()) { |
|
| 425 | 425 | |
| 426 | 426 | // Show the merge tags if the field is a list view |
| 427 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
| 427 | + $is_list = (preg_match('/_list-/ism', $name)); |
|
| 428 | 428 | |
| 429 | 429 | // Or is a single entry view |
| 430 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
| 431 | - $show = ( $is_single || $is_list ); |
|
| 430 | + $is_single = (preg_match('/single_/ism', $name)); |
|
| 431 | + $show = ($is_single || $is_list); |
|
| 432 | 432 | |
| 433 | 433 | $class = ''; |
| 434 | 434 | // and $add_merge_tags is not false |
| 435 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
| 435 | + if ($show && $add_merge_tags !== false || $add_merge_tags === 'force') { |
|
| 436 | 436 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - $class .= !empty( $args['class'] ) ? $args['class'] : 'widefat'; |
|
| 440 | - $type = !empty( $args['type'] ) ? $args['type'] : 'text'; |
|
| 439 | + $class .= !empty($args['class']) ? $args['class'] : 'widefat'; |
|
| 440 | + $type = !empty($args['type']) ? $args['type'] : 'text'; |
|
| 441 | 441 | |
| 442 | - return '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="'.esc_attr($type).'" value="'. esc_attr( $current ) .'" class="'.esc_attr( $class ).'">'; |
|
| 442 | + return '<input name="'.esc_attr($name).'" id="'.esc_attr($id).'" type="'.esc_attr($type).'" value="'.esc_attr($current).'" class="'.esc_attr($class).'">'; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -451,24 +451,24 @@ discard block |
||
| 451 | 451 | * @param array $args Field settings, including `class` key for CSS class |
| 452 | 452 | * @return string [html tags] |
| 453 | 453 | */ |
| 454 | - public static function render_textarea_option( $name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array() ) { |
|
| 454 | + public static function render_textarea_option($name = '', $id = '', $current = '', $add_merge_tags = NULL, $args = array()) { |
|
| 455 | 455 | |
| 456 | 456 | // Show the merge tags if the field is a list view |
| 457 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
| 457 | + $is_list = (preg_match('/_list-/ism', $name)); |
|
| 458 | 458 | |
| 459 | 459 | // Or is a single entry view |
| 460 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
| 461 | - $show = ( $is_single || $is_list ); |
|
| 460 | + $is_single = (preg_match('/single_/ism', $name)); |
|
| 461 | + $show = ($is_single || $is_list); |
|
| 462 | 462 | |
| 463 | 463 | $class = ''; |
| 464 | 464 | // and $add_merge_tags is not false |
| 465 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
| 465 | + if ($show && $add_merge_tags !== false || $add_merge_tags === 'force') { |
|
| 466 | 466 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - $class .= !empty( $args['class'] ) ? 'widefat '.$args['class'] : 'widefat'; |
|
| 469 | + $class .= !empty($args['class']) ? 'widefat '.$args['class'] : 'widefat'; |
|
| 470 | 470 | |
| 471 | - return '<textarea name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" class="'.esc_attr( $class ).'">'. esc_textarea( $current ) .'</textarea>'; |
|
| 471 | + return '<textarea name="'.esc_attr($name).'" id="'.esc_attr($id).'" class="'.esc_attr($class).'">'.esc_textarea($current).'</textarea>'; |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -480,11 +480,11 @@ discard block |
||
| 480 | 480 | * @param string $current [current value] |
| 481 | 481 | * @return string [html tags] |
| 482 | 482 | */ |
| 483 | - public static function render_select_option( $name = '', $id = '', $choices, $current = '' ) { |
|
| 483 | + public static function render_select_option($name = '', $id = '', $choices, $current = '') { |
|
| 484 | 484 | |
| 485 | - $output = '<select name="'. $name .'" id="'. $id .'">'; |
|
| 486 | - foreach( $choices as $value => $label ) { |
|
| 487 | - $output .= '<option value="'. esc_attr( $value ) .'" '. selected( $value, $current, false ) .'>'. esc_html( $label ) .'</option>'; |
|
| 485 | + $output = '<select name="'.$name.'" id="'.$id.'">'; |
|
| 486 | + foreach ($choices as $value => $label) { |
|
| 487 | + $output .= '<option value="'.esc_attr($value).'" '.selected($value, $current, false).'>'.esc_html($label).'</option>'; |
|
| 488 | 488 | } |
| 489 | 489 | $output .= '</select>'; |
| 490 | 490 | |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | * @since 1.15 |
| 26 | 26 | */ |
| 27 | 27 | private function add_hooks() { |
| 28 | - add_action( 'personal_options', array( $this, 'user_field' ) ); |
|
| 29 | - add_action( 'personal_options_update', array( $this, 'update_user_meta_value' ) ); |
|
| 30 | - add_action( 'edit_user_profile_update', array( $this, 'update_user_meta_value' ) ); |
|
| 31 | - add_action( 'admin_enqueue_scripts', array( $this, 'maybe_enqueue_script' ), 1000 ); |
|
| 32 | - add_action( 'update_option_active_plugins', array( $this, 'flush_related_plugins_transient' ) ); |
|
| 33 | - add_action( 'update_option_active_sitewide_plugins', array( $this, 'flush_related_plugins_transient' ) ); |
|
| 28 | + add_action('personal_options', array($this, 'user_field')); |
|
| 29 | + add_action('personal_options_update', array($this, 'update_user_meta_value')); |
|
| 30 | + add_action('edit_user_profile_update', array($this, 'update_user_meta_value')); |
|
| 31 | + add_action('admin_enqueue_scripts', array($this, 'maybe_enqueue_script'), 1000); |
|
| 32 | + add_action('update_option_active_plugins', array($this, 'flush_related_plugins_transient')); |
|
| 33 | + add_action('update_option_active_sitewide_plugins', array($this, 'flush_related_plugins_transient')); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | - public static function maybe_enqueue_script( $hook ) { |
|
| 45 | + public static function maybe_enqueue_script($hook) { |
|
| 46 | 46 | global $pagenow; |
| 47 | 47 | |
| 48 | 48 | // Don't show if not GravityView page, or if we're on the Widgets page |
| 49 | - if ( ! gravityview_is_admin_page( $hook ) || $pagenow === 'widgets.php' ) { |
|
| 49 | + if (!gravityview_is_admin_page($hook) || $pagenow === 'widgets.php') { |
|
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -55,17 +55,17 @@ discard block |
||
| 55 | 55 | * @since 1.15 |
| 56 | 56 | * @param boolean $display_beacon Default: `true` |
| 57 | 57 | */ |
| 58 | - $display_support_port = apply_filters( 'gravityview/support_port/display', self::show_for_user() ); |
|
| 58 | + $display_support_port = apply_filters('gravityview/support_port/display', self::show_for_user()); |
|
| 59 | 59 | |
| 60 | - if ( empty( $display_support_port ) ) { |
|
| 61 | - do_action( 'gravityview_log_debug', __METHOD__ . ' - Not showing Support Port' ); |
|
| 60 | + if (empty($display_support_port)) { |
|
| 61 | + do_action('gravityview_log_debug', __METHOD__.' - Not showing Support Port'); |
|
| 62 | 62 | |
| 63 | 63 | return; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 66 | + $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 67 | 67 | |
| 68 | - wp_enqueue_script( 'gravityview-support', plugins_url( 'assets/js/support' . $script_debug . '.js', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version, true ); |
|
| 68 | + wp_enqueue_script('gravityview-support', plugins_url('assets/js/support'.$script_debug.'.js', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version, true); |
|
| 69 | 69 | |
| 70 | 70 | self::_localize_script(); |
| 71 | 71 | } |
@@ -80,28 +80,28 @@ discard block |
||
| 80 | 80 | private static function _localize_script() { |
| 81 | 81 | |
| 82 | 82 | $translation = array( |
| 83 | - 'agentLabel' => __( 'GravityView Support', 'gravityview' ), |
|
| 84 | - 'searchLabel' => __( 'Search GravityView Docs', 'gravityview' ), |
|
| 85 | - 'searchErrorLabel' => __( 'Your search timed out. Please double-check your internet connection and try again.', 'gravityview' ), |
|
| 86 | - 'noResultsLabel' => _x( 'No results found for', 'a support form search has returned empty for the following word', 'gravityview' ), |
|
| 87 | - 'contactLabel' => __( 'Contact Support', 'gravityview' ), |
|
| 88 | - 'attachFileLabel' => __( 'Attach a screenshot or file', 'gravityview' ), |
|
| 89 | - 'attachFileError' => __( 'The maximum file size is 10 MB', 'gravityview' ), |
|
| 90 | - 'nameLabel' => __( 'Your Name', 'gravityview' ), |
|
| 91 | - 'nameError' => __( 'Please enter your name', 'gravityview' ), |
|
| 92 | - 'emailLabel' => __( 'Email address', 'gravityview' ), |
|
| 93 | - 'emailError' => __( 'Please enter a valid email address', 'gravityview' ), |
|
| 94 | - 'subjectLabel' => __( 'Subject', 'gravityview' ), |
|
| 95 | - 'subjectError' => _x( 'Please enter a subject', 'Error shown when submitting support request and there is no subject provided', 'gravityview' ), |
|
| 96 | - 'messageLabel' => __( 'How can we help you?', 'gravityview' ), |
|
| 97 | - 'messageError' => _x( 'Please enter a message', 'Error shown when submitting support request and there is no message provided', 'gravityview' ), |
|
| 98 | - 'contactSuccessLabel' => __( 'Message sent!', 'gravityview' ), |
|
| 99 | - 'contactSuccessDescription' => __( 'Thanks for reaching out! Someone from the GravityView team will get back to you soon.', 'gravityview' ), |
|
| 83 | + 'agentLabel' => __('GravityView Support', 'gravityview'), |
|
| 84 | + 'searchLabel' => __('Search GravityView Docs', 'gravityview'), |
|
| 85 | + 'searchErrorLabel' => __('Your search timed out. Please double-check your internet connection and try again.', 'gravityview'), |
|
| 86 | + 'noResultsLabel' => _x('No results found for', 'a support form search has returned empty for the following word', 'gravityview'), |
|
| 87 | + 'contactLabel' => __('Contact Support', 'gravityview'), |
|
| 88 | + 'attachFileLabel' => __('Attach a screenshot or file', 'gravityview'), |
|
| 89 | + 'attachFileError' => __('The maximum file size is 10 MB', 'gravityview'), |
|
| 90 | + 'nameLabel' => __('Your Name', 'gravityview'), |
|
| 91 | + 'nameError' => __('Please enter your name', 'gravityview'), |
|
| 92 | + 'emailLabel' => __('Email address', 'gravityview'), |
|
| 93 | + 'emailError' => __('Please enter a valid email address', 'gravityview'), |
|
| 94 | + 'subjectLabel' => __('Subject', 'gravityview'), |
|
| 95 | + 'subjectError' => _x('Please enter a subject', 'Error shown when submitting support request and there is no subject provided', 'gravityview'), |
|
| 96 | + 'messageLabel' => __('How can we help you?', 'gravityview'), |
|
| 97 | + 'messageError' => _x('Please enter a message', 'Error shown when submitting support request and there is no message provided', 'gravityview'), |
|
| 98 | + 'contactSuccessLabel' => __('Message sent!', 'gravityview'), |
|
| 99 | + 'contactSuccessDescription' => __('Thanks for reaching out! Someone from the GravityView team will get back to you soon.', 'gravityview'), |
|
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | - $response = GravityView_Settings::getSetting( 'license_key_response' ); |
|
| 102 | + $response = GravityView_Settings::getSetting('license_key_response'); |
|
| 103 | 103 | |
| 104 | - $response = wp_parse_args( $response, array( |
|
| 104 | + $response = wp_parse_args($response, array( |
|
| 105 | 105 | 'license' => '', |
| 106 | 106 | 'message' => '', |
| 107 | 107 | 'license_key' => '', |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | 'payment_id' => '', |
| 113 | 113 | 'customer_name' => '', |
| 114 | 114 | 'customer_email' => '', |
| 115 | - ) ); |
|
| 115 | + )); |
|
| 116 | 116 | |
| 117 | 117 | // This is just HTML we don't need. |
| 118 | - unset( $response['message'] ); |
|
| 118 | + unset($response['message']); |
|
| 119 | 119 | |
| 120 | - switch ( intval( $response['license_limit'] ) ) { |
|
| 120 | + switch (intval($response['license_limit'])) { |
|
| 121 | 121 | case 1: |
| 122 | 122 | $package = 'Sol'; |
| 123 | 123 | break; |
@@ -128,17 +128,17 @@ discard block |
||
| 128 | 128 | $package = 'Interstellar'; |
| 129 | 129 | break; |
| 130 | 130 | default: |
| 131 | - $package = sprintf( '%d-Site License', $response['license_limit'] ); |
|
| 131 | + $package = sprintf('%d-Site License', $response['license_limit']); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $data = array( |
| 135 | - 'email' => GravityView_Settings::getSetting( 'support-email' ), |
|
| 135 | + 'email' => GravityView_Settings::getSetting('support-email'), |
|
| 136 | 136 | 'name' => $response['customer_name'], |
| 137 | - 'Valid License?' => ucwords( $response['license'] ), |
|
| 137 | + 'Valid License?' => ucwords($response['license']), |
|
| 138 | 138 | 'License Key' => $response['license_key'], |
| 139 | 139 | 'License Level' => $package, |
| 140 | - 'Site Admin Email' => get_bloginfo( 'admin_email' ), |
|
| 141 | - 'Support Email' => GravityView_Settings::getSetting( 'support-email' ), |
|
| 140 | + 'Site Admin Email' => get_bloginfo('admin_email'), |
|
| 141 | + 'Support Email' => GravityView_Settings::getSetting('support-email'), |
|
| 142 | 142 | 'License Limit' => $response['license_limit'], |
| 143 | 143 | 'Site Count' => $response['site_count'], |
| 144 | 144 | 'License Expires' => $response['expires'], |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | 'Payment ID' => $response['payment_id'], |
| 147 | 147 | 'Payment Name' => $response['customer_name'], |
| 148 | 148 | 'Payment Email' => $response['customer_email'], |
| 149 | - 'WordPress Version' => get_bloginfo( 'version', 'display' ), |
|
| 149 | + 'WordPress Version' => get_bloginfo('version', 'display'), |
|
| 150 | 150 | 'PHP Version' => phpversion(), |
| 151 | 151 | 'GravityView Version' => GravityView_Plugin::version, |
| 152 | 152 | 'Gravity Forms Version' => GFForms::$version, |
@@ -154,15 +154,15 @@ discard block |
||
| 154 | 154 | ); |
| 155 | 155 | |
| 156 | 156 | $localization_data = array( |
| 157 | - 'contactEnabled' => (int)current_user_can( 'gravityview_contact_support' ), // @todo use GVCommon::has_cap() after merge |
|
| 158 | - 'protocol' => ( is_ssl() ? 'https' : 'http' ), |
|
| 157 | + 'contactEnabled' => (int)current_user_can('gravityview_contact_support'), // @todo use GVCommon::has_cap() after merge |
|
| 158 | + 'protocol' => (is_ssl() ? 'https' : 'http'), |
|
| 159 | 159 | 'data' => $data, |
| 160 | 160 | 'translation' => $translation, |
| 161 | 161 | ); |
| 162 | 162 | |
| 163 | - wp_localize_script( 'gravityview-support', 'gvSupport', $localization_data ); |
|
| 163 | + wp_localize_script('gravityview-support', 'gvSupport', $localization_data); |
|
| 164 | 164 | |
| 165 | - unset( $localization_data, $data, $translation, $response, $package ); |
|
| 165 | + unset($localization_data, $data, $translation, $response, $package); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -173,36 +173,36 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | static private function get_related_plugins_and_extensions() { |
| 175 | 175 | |
| 176 | - if ( ! function_exists( 'wp_get_active_and_valid_plugins' ) ) { |
|
| 176 | + if (!function_exists('wp_get_active_and_valid_plugins')) { |
|
| 177 | 177 | return 'Running < WP 3.0'; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - $extensions = get_site_transient( self::related_plugins_key ); |
|
| 180 | + $extensions = get_site_transient(self::related_plugins_key); |
|
| 181 | 181 | |
| 182 | - if ( empty( $extensions ) ) { |
|
| 182 | + if (empty($extensions)) { |
|
| 183 | 183 | |
| 184 | 184 | $active_plugins = wp_get_active_and_valid_plugins(); |
| 185 | 185 | $extensions = array(); |
| 186 | - foreach ( $active_plugins as $active_plugin ) { |
|
| 186 | + foreach ($active_plugins as $active_plugin) { |
|
| 187 | 187 | |
| 188 | 188 | // Match gravityview, gravity-forms, gravityforms, gravitate |
| 189 | - if ( ! preg_match( '/(gravityview|gravity-?forms|gravitate)/ism', $active_plugin ) ) { |
|
| 189 | + if (!preg_match('/(gravityview|gravity-?forms|gravitate)/ism', $active_plugin)) { |
|
| 190 | 190 | continue; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - $plugin_data = get_plugin_data( $active_plugin ); |
|
| 193 | + $plugin_data = get_plugin_data($active_plugin); |
|
| 194 | 194 | |
| 195 | - $extensions[] = sprintf( '%s %s', $plugin_data['Name'], $plugin_data['Version'] ); |
|
| 195 | + $extensions[] = sprintf('%s %s', $plugin_data['Name'], $plugin_data['Version']); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if( ! empty( $extensions ) ) { |
|
| 199 | - set_site_transient( self::related_plugins_key, $extensions, HOUR_IN_SECONDS ); |
|
| 198 | + if (!empty($extensions)) { |
|
| 199 | + set_site_transient(self::related_plugins_key, $extensions, HOUR_IN_SECONDS); |
|
| 200 | 200 | } else { |
| 201 | 201 | return 'There was an error fetching related plugins.'; |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - return implode( '<br />', $extensions ); |
|
| 205 | + return implode('<br />', $extensions); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | * @since 1.15 |
| 213 | 213 | */ |
| 214 | 214 | public function flush_related_plugins_transient() { |
| 215 | - if ( function_exists( 'delete_site_transient' ) ) { |
|
| 216 | - delete_site_transient( self::related_plugins_key ); |
|
| 215 | + if (function_exists('delete_site_transient')) { |
|
| 216 | + delete_site_transient(self::related_plugins_key); |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
@@ -229,20 +229,20 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @return bool Whether to show GravityView support |
| 231 | 231 | */ |
| 232 | - static public function show_for_user( $user = 0 ) { |
|
| 232 | + static public function show_for_user($user = 0) { |
|
| 233 | 233 | |
| 234 | - if ( ! GVCommon::has_cap( 'gravityview_support_port' ) ) { |
|
| 234 | + if (!GVCommon::has_cap('gravityview_support_port')) { |
|
| 235 | 235 | return false; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - $pref = get_user_option( self::user_pref_name, $user ); |
|
| 238 | + $pref = get_user_option(self::user_pref_name, $user); |
|
| 239 | 239 | |
| 240 | 240 | // Not set; default to plugin setting |
| 241 | - if ( false === $pref ) { |
|
| 242 | - return GravityView_Settings::getSetting( 'support_port' ); |
|
| 241 | + if (false === $pref) { |
|
| 242 | + return GravityView_Settings::getSetting('support_port'); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - return ! empty( $pref ); |
|
| 245 | + return !empty($pref); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -255,9 +255,9 @@ discard block |
||
| 255 | 255 | * |
| 256 | 256 | * @return void |
| 257 | 257 | */ |
| 258 | - public function update_user_meta_value( $user_id ) { |
|
| 259 | - if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST[ self::user_pref_name ] ) ) { |
|
| 260 | - update_user_meta( $user_id, self::user_pref_name, intval( $_POST[ self::user_pref_name ] ) ); |
|
| 258 | + public function update_user_meta_value($user_id) { |
|
| 259 | + if (current_user_can('edit_user', $user_id) && isset($_POST[self::user_pref_name])) { |
|
| 260 | + update_user_meta($user_id, self::user_pref_name, intval($_POST[self::user_pref_name])); |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * |
| 273 | 273 | * @return void |
| 274 | 274 | */ |
| 275 | - public function user_field( $user ) { |
|
| 275 | + public function user_field($user) { |
|
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | 278 | * @filter `gravityview/support_port/show_profile_setting` Should the "GravityView Support Port" setting be shown on user profiles? |
@@ -282,21 +282,21 @@ discard block |
||
| 282 | 282 | * @param boolean $allow_profile_setting Default: `true`, if the user has the `gravityview_support_port` capability, which defaults to true for Contributors and higher |
| 283 | 283 | * @param WP_User $user Current user object |
| 284 | 284 | */ |
| 285 | - $allow_profile_setting = apply_filters( 'gravityview/support_port/show_profile_setting', current_user_can( 'gravityview_support_port' ), $user ); |
|
| 285 | + $allow_profile_setting = apply_filters('gravityview/support_port/show_profile_setting', current_user_can('gravityview_support_port'), $user); |
|
| 286 | 286 | |
| 287 | - if ( $allow_profile_setting && current_user_can( 'edit_user', $user->ID ) ) { |
|
| 287 | + if ($allow_profile_setting && current_user_can('edit_user', $user->ID)) { |
|
| 288 | 288 | ?> |
| 289 | 289 | <table class="form-table"> |
| 290 | 290 | <tbody> |
| 291 | 291 | <tr class="user-gravityview-support-button-wrap"> |
| 292 | - <th scope="row"><?php _e( 'GravityView Support Port', 'gravityview' ); ?></th> |
|
| 292 | + <th scope="row"><?php _e('GravityView Support Port', 'gravityview'); ?></th> |
|
| 293 | 293 | <td> |
| 294 | 294 | <fieldset> |
| 295 | - <legend class="screen-reader-text"><span><?php _e( 'GravityView Support Port', 'gravityview' ) ?></span></legend> |
|
| 295 | + <legend class="screen-reader-text"><span><?php _e('GravityView Support Port', 'gravityview') ?></span></legend> |
|
| 296 | 296 | <label> |
| 297 | - <input name="<?php echo esc_attr( self::user_pref_name ); ?>" type="hidden" value="0"/> |
|
| 298 | - <input name="<?php echo esc_attr( self::user_pref_name ); ?>" type="checkbox" value="1" <?php checked( self::show_for_user( $user->ID ) ); ?> /> |
|
| 299 | - <?php esc_html_e( 'Show GravityView Support Port when on a GravityView-related page', 'gravityview' ); ?> |
|
| 297 | + <input name="<?php echo esc_attr(self::user_pref_name); ?>" type="hidden" value="0"/> |
|
| 298 | + <input name="<?php echo esc_attr(self::user_pref_name); ?>" type="checkbox" value="1" <?php checked(self::show_for_user($user->ID)); ?> /> |
|
| 299 | + <?php esc_html_e('Show GravityView Support Port when on a GravityView-related page', 'gravityview'); ?> |
|
| 300 | 300 | </label> |
| 301 | 301 | </fieldset> |
| 302 | 302 | </td> |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | var $name = 'checkbox'; |
| 6 | 6 | |
| 7 | - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); |
|
| 7 | + var $search_operators = array('is', 'in', 'not in', 'isnot', 'contains'); |
|
| 8 | 8 | |
| 9 | 9 | var $_gf_field_class_name = 'GF_Field_Checkbox'; |
| 10 | 10 | |