@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | /** |
| 215 | 215 | * Generate the script tags necessary for the Gravity Forms Merge Tag picker to work. |
| 216 | 216 | * |
| 217 | - * @param mixed $curr_form Form ID |
|
| 217 | + * @param string $curr_form Form ID |
|
| 218 | 218 | * @return null|string Merge tags html; NULL if $curr_form isn't defined. |
| 219 | 219 | */ |
| 220 | 220 | public static function render_merge_tags_scripts( $curr_form ) { |
@@ -290,7 +290,6 @@ discard block |
||
| 290 | 290 | * Render shortcode hint in the Publish metabox |
| 291 | 291 | * |
| 292 | 292 | * @access public |
| 293 | - * @param object $post |
|
| 294 | 293 | * @return void |
| 295 | 294 | */ |
| 296 | 295 | function render_shortcode_hint() { |
@@ -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 | } |
@@ -95,7 +95,7 @@ |
||
| 95 | 95 | * @param string $icon_class_name Icon class used in vertical tabs. Supports non-dashicon. If dashicons, no need for `dashicons ` prefix |
| 96 | 96 | * @param string $callback Function to render the metabox, if $file is not defined. |
| 97 | 97 | * @param null $callback_args Arguments passed to the callback |
| 98 | - * @return void |
|
| 98 | + * @return GravityView_Metabox_Tab |
|
| 99 | 99 | */ |
| 100 | 100 | function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = null ) { |
| 101 | 101 | |
@@ -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 | |
@@ -144,7 +144,6 @@ |
||
| 144 | 144 | * Enqueue scripts and styles |
| 145 | 145 | * |
| 146 | 146 | * @access public |
| 147 | - * @param mixed $hook |
|
| 148 | 147 | * @return void |
| 149 | 148 | */ |
| 150 | 149 | function add_scripts_and_styles() { |
@@ -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 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @uses GravityView_frontend::get_search_criteria() Convert the $_POST search request into a properly formatted request. |
| 172 | 172 | * @access public |
| 173 | - * @return void|boolean |
|
| 173 | + * @return null|false |
|
| 174 | 174 | */ |
| 175 | 175 | public function process_bulk_action() { |
| 176 | 176 | if ( ! class_exists( 'RGForms' ) ) { |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @param array|boolean $entries If array, array of entry IDs that are to be updated. If true: update all entries. |
| 253 | 253 | * @param int $approved Approved status. If `0`: unapproved, if not empty, `Approved` |
| 254 | 254 | * @param int $form_id The Gravity Forms Form ID |
| 255 | - * @return boolean|void |
|
| 255 | + * @return false|null |
|
| 256 | 256 | */ |
| 257 | 257 | private static function update_bulk( $entries, $approved, $form_id ) { |
| 258 | 258 | |
@@ -284,7 +284,6 @@ discard block |
||
| 284 | 284 | * |
| 285 | 285 | * @access public |
| 286 | 286 | * @static |
| 287 | - * @param int $lead_id (default: 0) |
|
| 288 | 287 | * @param int $approved (default: 0) |
| 289 | 288 | * @param int $form_id (default: 0) |
| 290 | 289 | * @param int $approvedcolumn (default: 0) |
@@ -470,7 +469,7 @@ discard block |
||
| 470 | 469 | * @access public |
| 471 | 470 | * @static |
| 472 | 471 | * @param mixed $form GF Form or Form ID |
| 473 | - * @return false|null|string Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set. |
|
| 472 | + * @return integer Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set. |
|
| 474 | 473 | */ |
| 475 | 474 | static public function get_approved_column( $form ) { |
| 476 | 475 | |
@@ -27,29 +27,29 @@ discard block |
||
| 27 | 27 | /** Edit Gravity Form page */ |
| 28 | 28 | |
| 29 | 29 | // Add button to left menu |
| 30 | - add_filter( 'gform_add_field_buttons', array( $this, 'add_field_buttons' ) ); |
|
| 30 | + add_filter('gform_add_field_buttons', array($this, 'add_field_buttons')); |
|
| 31 | 31 | // Set defaults |
| 32 | - add_action( 'gform_editor_js_set_default_values', array( $this, 'set_defaults' ) ); |
|
| 32 | + add_action('gform_editor_js_set_default_values', array($this, 'set_defaults')); |
|
| 33 | 33 | |
| 34 | 34 | /** gf_entries page - entries table screen */ |
| 35 | 35 | |
| 36 | 36 | // capture bulk actions |
| 37 | - add_action( 'init', array( $this, 'process_bulk_action') ); |
|
| 37 | + add_action('init', array($this, 'process_bulk_action')); |
|
| 38 | 38 | // add hidden field with approve status |
| 39 | - add_action( 'gform_entries_first_column', array( $this, 'add_entry_approved_hidden_input' ), 1, 5 ); |
|
| 39 | + add_action('gform_entries_first_column', array($this, 'add_entry_approved_hidden_input'), 1, 5); |
|
| 40 | 40 | // process ajax approve entry requests |
| 41 | - add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved')); |
|
| 41 | + add_action('wp_ajax_gv_update_approved', array($this, 'ajax_update_approved')); |
|
| 42 | 42 | |
| 43 | 43 | // in case entry is edited (on admin or frontend) |
| 44 | - add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2); |
|
| 44 | + add_action('gform_after_update_entry', array($this, 'after_update_entry_update_approved_meta'), 10, 2); |
|
| 45 | 45 | |
| 46 | - add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) ); |
|
| 46 | + add_filter('gravityview_tooltips', array($this, 'tooltips')); |
|
| 47 | 47 | |
| 48 | 48 | // adding styles and scripts |
| 49 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
| 49 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts_and_styles')); |
|
| 50 | 50 | // bypass Gravity Forms no-conflict mode |
| 51 | - add_filter( 'gform_noconflict_scripts', array( $this, 'register_gform_noconflict_script' ) ); |
|
| 52 | - add_filter( 'gform_noconflict_styles', array( $this, 'register_gform_noconflict_style' ) ); |
|
| 51 | + add_filter('gform_noconflict_scripts', array($this, 'register_gform_noconflict_script')); |
|
| 52 | + add_filter('gform_noconflict_styles', array($this, 'register_gform_noconflict_style')); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return array Tooltips array with GravityView fields tooltip |
| 61 | 61 | */ |
| 62 | - function tooltips( $tooltips ) { |
|
| 62 | + function tooltips($tooltips) { |
|
| 63 | 63 | |
| 64 | 64 | $tooltips['form_gravityview_fields'] = array( |
| 65 | 65 | 'title' => __('GravityView Fields', 'gravityview'), |
| 66 | - 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview'), |
|
| 66 | + 'value' => __('Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview'), |
|
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | 69 | return $tooltips; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @param mixed $field_groups |
| 78 | 78 | * @return array Array of fields |
| 79 | 79 | */ |
| 80 | - function add_field_buttons( $field_groups ) { |
|
| 80 | + function add_field_buttons($field_groups) { |
|
| 81 | 81 | |
| 82 | 82 | $gravityview_fields = array( |
| 83 | 83 | 'name' => 'gravityview_fields', |
@@ -85,20 +85,20 @@ discard block |
||
| 85 | 85 | 'fields' => array( |
| 86 | 86 | array( |
| 87 | 87 | 'class' => 'button', |
| 88 | - 'value' => __( 'Approve/Reject', 'gravityview' ), |
|
| 88 | + 'value' => __('Approve/Reject', 'gravityview'), |
|
| 89 | 89 | 'onclick' => "StartAddField('gravityviewapproved_admin');", |
| 90 | 90 | 'data-type' => 'gravityviewapproved_admin' |
| 91 | 91 | ), |
| 92 | 92 | array( |
| 93 | 93 | 'class' => 'button', |
| 94 | - 'value' => __( 'User Opt-In', 'gravityview' ), |
|
| 94 | + 'value' => __('User Opt-In', 'gravityview'), |
|
| 95 | 95 | 'onclick' => "StartAddField('gravityviewapproved');", |
| 96 | 96 | 'data-type' => 'gravityviewapproved' |
| 97 | 97 | ), |
| 98 | 98 | ) |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - array_push( $field_groups, $gravityview_fields ); |
|
| 101 | + array_push($field_groups, $gravityview_fields); |
|
| 102 | 102 | |
| 103 | 103 | return $field_groups; |
| 104 | 104 | } |
@@ -115,16 +115,16 @@ discard block |
||
| 115 | 115 | function set_defaults() { |
| 116 | 116 | ?> |
| 117 | 117 | case 'gravityviewapproved_admin': |
| 118 | - field.label = "<?php _e( 'Approved? (Admin-only)', 'gravityview' ); ?>"; |
|
| 118 | + field.label = "<?php _e('Approved? (Admin-only)', 'gravityview'); ?>"; |
|
| 119 | 119 | |
| 120 | - field.adminLabel = "<?php _e( 'Approved?', 'gravityview' ); ?>"; |
|
| 120 | + field.adminLabel = "<?php _e('Approved?', 'gravityview'); ?>"; |
|
| 121 | 121 | field.adminOnly = true; |
| 122 | 122 | |
| 123 | 123 | field.choices = null; |
| 124 | 124 | field.inputs = null; |
| 125 | 125 | |
| 126 | 126 | if( !field.choices ) { |
| 127 | - field.choices = new Array( new Choice("<?php _e( 'Approved', 'gravityview' ); ?>") ); |
|
| 127 | + field.choices = new Array( new Choice("<?php _e('Approved', 'gravityview'); ?>") ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | field.inputs = new Array(); |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | break; |
| 139 | 139 | case 'gravityviewapproved': |
| 140 | - field.label = "<?php _e( 'Show Entry on Website', 'gravityview' ); ?>"; |
|
| 140 | + field.label = "<?php _e('Show Entry on Website', 'gravityview'); ?>"; |
|
| 141 | 141 | |
| 142 | - field.adminLabel = "<?php _e( 'Opt-In', 'gravityview' ); ?>"; |
|
| 142 | + field.adminLabel = "<?php _e('Opt-In', 'gravityview'); ?>"; |
|
| 143 | 143 | field.adminOnly = false; |
| 144 | 144 | |
| 145 | 145 | field.choices = null; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | if( !field.choices ) { |
| 149 | 149 | field.choices = new Array( |
| 150 | - new Choice("<?php _e( 'Yes, display my entry on the website', 'gravityview' ); ?>") |
|
| 150 | + new Choice("<?php _e('Yes, display my entry on the website', 'gravityview'); ?>") |
|
| 151 | 151 | ); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -173,17 +173,17 @@ discard block |
||
| 173 | 173 | * @return void|boolean |
| 174 | 174 | */ |
| 175 | 175 | public function process_bulk_action() { |
| 176 | - if ( ! class_exists( 'RGForms' ) ) { |
|
| 176 | + if (!class_exists('RGForms')) { |
|
| 177 | 177 | return; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // gforms_update_note is sent when bulk editing entry notes. We don't want to process then. |
| 181 | - if ( 'bulk' === RGForms::post( 'action' ) && empty( $_POST['gforms_update_note'] ) ) { |
|
| 181 | + if ('bulk' === RGForms::post('action') && empty($_POST['gforms_update_note'])) { |
|
| 182 | 182 | |
| 183 | - check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' ); |
|
| 183 | + check_admin_referer('gforms_entry_list', 'gforms_entry_list'); |
|
| 184 | 184 | |
| 185 | 185 | // The action is formatted like: approve-16 or disapprove-16, where the first word is the name of the action and the second is the ID of the form. Bulk action 2 is the bottom bulk action select form. |
| 186 | - $bulk_action = ! empty( $_POST['bulk_action'] ) ? $_POST['bulk_action'] : $_POST['bulk_action2']; |
|
| 186 | + $bulk_action = !empty($_POST['bulk_action']) ? $_POST['bulk_action'] : $_POST['bulk_action2']; |
|
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | 189 | * The extra '-' is to make sure that there are at *least* two items in array. |
@@ -191,27 +191,27 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | $bulk_action .= '-'; |
| 193 | 193 | |
| 194 | - list( $approved_status, $form_id ) = explode( '-', $bulk_action ); |
|
| 194 | + list($approved_status, $form_id) = explode('-', $bulk_action); |
|
| 195 | 195 | |
| 196 | - if ( empty( $form_id ) ) { |
|
| 197 | - do_action( 'gravityview_log_error', '[process_bulk_action] Form ID is empty from parsing bulk action.', $bulk_action ); |
|
| 196 | + if (empty($form_id)) { |
|
| 197 | + do_action('gravityview_log_error', '[process_bulk_action] Form ID is empty from parsing bulk action.', $bulk_action); |
|
| 198 | 198 | return false; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | // All entries are set to be updated, not just the visible ones |
| 202 | - if ( ! empty( $_POST['all_entries'] ) ) { |
|
| 202 | + if (!empty($_POST['all_entries'])) { |
|
| 203 | 203 | |
| 204 | 204 | // Convert the current entry search into GF-formatted search criteria |
| 205 | 205 | $search = array( |
| 206 | - 'search_field' => isset( $_POST['f'] ) ? $_POST['f'][0] : 0, |
|
| 207 | - 'search_value' => isset( $_POST['v'][0] ) ? $_POST['v'][0] : '', |
|
| 208 | - 'search_operator' => isset( $_POST['o'][0] ) ? $_POST['o'][0] : 'contains', |
|
| 206 | + 'search_field' => isset($_POST['f']) ? $_POST['f'][0] : 0, |
|
| 207 | + 'search_value' => isset($_POST['v'][0]) ? $_POST['v'][0] : '', |
|
| 208 | + 'search_operator' => isset($_POST['o'][0]) ? $_POST['o'][0] : 'contains', |
|
| 209 | 209 | ); |
| 210 | 210 | |
| 211 | - $search_criteria = GravityView_frontend::get_search_criteria( $search, $form_id ); |
|
| 211 | + $search_criteria = GravityView_frontend::get_search_criteria($search, $form_id); |
|
| 212 | 212 | |
| 213 | 213 | // Get all the entry IDs for the form |
| 214 | - $entries = gravityview_get_entry_ids( $form_id, $search_criteria ); |
|
| 214 | + $entries = gravityview_get_entry_ids($form_id, $search_criteria); |
|
| 215 | 215 | |
| 216 | 216 | } else { |
| 217 | 217 | |
@@ -219,22 +219,22 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - if ( empty( $entries ) ) { |
|
| 223 | - do_action( 'gravityview_log_error', '[process_bulk_action] Entries are empty' ); |
|
| 222 | + if (empty($entries)) { |
|
| 223 | + do_action('gravityview_log_error', '[process_bulk_action] Entries are empty'); |
|
| 224 | 224 | return false; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $entry_count = count( $entries ) > 1 ? sprintf( __( '%d entries', 'gravityview' ), count( $entries ) ) : __( '1 entry', 'gravityview' ); |
|
| 227 | + $entry_count = count($entries) > 1 ? sprintf(__('%d entries', 'gravityview'), count($entries)) : __('1 entry', 'gravityview'); |
|
| 228 | 228 | |
| 229 | - switch ( $approved_status ) { |
|
| 229 | + switch ($approved_status) { |
|
| 230 | 230 | case 'approve': |
| 231 | - self::update_bulk( $entries, 1, $form_id ); |
|
| 232 | - $this->bulk_update_message = sprintf( __( '%s approved.', 'gravityview' ), $entry_count ); |
|
| 231 | + self::update_bulk($entries, 1, $form_id); |
|
| 232 | + $this->bulk_update_message = sprintf(__('%s approved.', 'gravityview'), $entry_count); |
|
| 233 | 233 | break; |
| 234 | 234 | |
| 235 | 235 | case 'unapprove': |
| 236 | - self::update_bulk( $entries, 0, $form_id ); |
|
| 237 | - $this->bulk_update_message = sprintf( __( '%s disapproved.', 'gravityview' ), $entry_count ); |
|
| 236 | + self::update_bulk($entries, 0, $form_id); |
|
| 237 | + $this->bulk_update_message = sprintf(__('%s disapproved.', 'gravityview'), $entry_count); |
|
| 238 | 238 | break; |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -254,25 +254,25 @@ discard block |
||
| 254 | 254 | * @param int $form_id The Gravity Forms Form ID |
| 255 | 255 | * @return boolean|void |
| 256 | 256 | */ |
| 257 | - private static function update_bulk( $entries, $approved, $form_id ) { |
|
| 257 | + private static function update_bulk($entries, $approved, $form_id) { |
|
| 258 | 258 | |
| 259 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
| 260 | - do_action( 'gravityview_log_error', __METHOD__ . ' Entries were empty or malformed.', $entries ); |
|
| 259 | + if (empty($entries) || ($entries !== true && !is_array($entries))) { |
|
| 260 | + do_action('gravityview_log_error', __METHOD__.' Entries were empty or malformed.', $entries); |
|
| 261 | 261 | return false; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 265 | - do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
|
| 264 | + if (!GVCommon::has_cap('gravityview_moderate_entries')) { |
|
| 265 | + do_action('gravityview_log_error', __METHOD__.' User does not have the `gravityview_moderate_entries` capability.'); |
|
| 266 | 266 | return false; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $approved = empty( $approved ) ? 0 : 'Approved'; |
|
| 269 | + $approved = empty($approved) ? 0 : 'Approved'; |
|
| 270 | 270 | |
| 271 | 271 | // calculate approved field id |
| 272 | - $approved_column_id = self::get_approved_column( $form_id ); |
|
| 272 | + $approved_column_id = self::get_approved_column($form_id); |
|
| 273 | 273 | |
| 274 | - foreach( $entries as $entry_id ) { |
|
| 275 | - self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
|
| 274 | + foreach ($entries as $entry_id) { |
|
| 275 | + self::update_approved((int)$entry_id, $approved, $form_id, $approved_column_id); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
@@ -290,39 +290,39 @@ discard block |
||
| 290 | 290 | * @param int $approvedcolumn (default: 0) |
| 291 | 291 | * @return boolean True: It worked; False: it failed |
| 292 | 292 | */ |
| 293 | - public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
|
| 293 | + public static function update_approved($entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
|
| 294 | 294 | |
| 295 | - if( !class_exists( 'GFAPI' ) ) { |
|
| 296 | - do_action( 'gravityview_log_error', __METHOD__ . 'GFAPI does not exist' ); |
|
| 295 | + if (!class_exists('GFAPI')) { |
|
| 296 | + do_action('gravityview_log_error', __METHOD__.'GFAPI does not exist'); |
|
| 297 | 297 | return false; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - if( empty( $approvedcolumn ) ) { |
|
| 301 | - $approvedcolumn = self::get_approved_column( $form_id ); |
|
| 300 | + if (empty($approvedcolumn)) { |
|
| 301 | + $approvedcolumn = self::get_approved_column($form_id); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | //get the entry |
| 305 | - $entry = GFAPI::get_entry( $entry_id ); |
|
| 305 | + $entry = GFAPI::get_entry($entry_id); |
|
| 306 | 306 | |
| 307 | 307 | //update entry |
| 308 | - $entry[ (string)$approvedcolumn ] = $approved; |
|
| 308 | + $entry[(string)$approvedcolumn] = $approved; |
|
| 309 | 309 | |
| 310 | 310 | /** @var bool|WP_Error $result */ |
| 311 | - $result = GFAPI::update_entry( $entry ); |
|
| 311 | + $result = GFAPI::update_entry($entry); |
|
| 312 | 312 | |
| 313 | 313 | /** |
| 314 | 314 | * GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves. |
| 315 | 315 | */ |
| 316 | - self::update_approved_meta( $entry_id, $approved ); |
|
| 316 | + self::update_approved_meta($entry_id, $approved); |
|
| 317 | 317 | |
| 318 | 318 | // add note to entry |
| 319 | - if( $result === true ) { |
|
| 320 | - $note = empty( $approved ) ? __( 'Disapproved the Entry for GravityView', 'gravityview' ) : __( 'Approved the Entry for GravityView', 'gravityview' ); |
|
| 319 | + if ($result === true) { |
|
| 320 | + $note = empty($approved) ? __('Disapproved the Entry for GravityView', 'gravityview') : __('Approved the Entry for GravityView', 'gravityview'); |
|
| 321 | 321 | |
| 322 | - if( class_exists( 'GravityView_Entry_Notes' ) ){ |
|
| 322 | + if (class_exists('GravityView_Entry_Notes')) { |
|
| 323 | 323 | global $current_user; |
| 324 | 324 | get_currentuserinfo(); |
| 325 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $current_user->display_name, $note ); |
|
| 325 | + GravityView_Entry_Notes::add_note($entry_id, $current_user->ID, $current_user->display_name, $note); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -330,11 +330,11 @@ discard block |
||
| 330 | 330 | * @see class-cache.php |
| 331 | 331 | * @since 1.5.1 |
| 332 | 332 | */ |
| 333 | - do_action( 'gravityview_clear_form_cache', $form_id ); |
|
| 333 | + do_action('gravityview_clear_form_cache', $form_id); |
|
| 334 | 334 | |
| 335 | - } else if( is_wp_error( $result ) ) { |
|
| 335 | + } else if (is_wp_error($result)) { |
|
| 336 | 336 | |
| 337 | - do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - Entry approval not updated: %s', $result->get_error_message() ) ); |
|
| 337 | + do_action('gravityview_log_error', __METHOD__.sprintf(' - Entry approval not updated: %s', $result->get_error_message())); |
|
| 338 | 338 | |
| 339 | 339 | $result = false; |
| 340 | 340 | } |
@@ -352,20 +352,20 @@ discard block |
||
| 352 | 352 | * @param int $entry_id ID of the Gravity Forms entry |
| 353 | 353 | * @return void |
| 354 | 354 | */ |
| 355 | - public static function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
|
| 355 | + public static function after_update_entry_update_approved_meta($form, $entry_id = NULL) { |
|
| 356 | 356 | |
| 357 | - $approvedcolumn = self::get_approved_column( $form['id'] ); |
|
| 357 | + $approvedcolumn = self::get_approved_column($form['id']); |
|
| 358 | 358 | |
| 359 | 359 | /** |
| 360 | 360 | * If the form doesn't contain the approve field, don't assume anything. |
| 361 | 361 | */ |
| 362 | - if( empty( $approvedcolumn ) ) { |
|
| 362 | + if (empty($approvedcolumn)) { |
|
| 363 | 363 | return; |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - $entry = GFAPI::get_entry( $entry_id ); |
|
| 366 | + $entry = GFAPI::get_entry($entry_id); |
|
| 367 | 367 | |
| 368 | - self::update_approved_meta( $entry_id, $entry[ (string)$approvedcolumn ] ); |
|
| 368 | + self::update_approved_meta($entry_id, $entry[(string)$approvedcolumn]); |
|
| 369 | 369 | |
| 370 | 370 | } |
| 371 | 371 | |
@@ -378,12 +378,12 @@ discard block |
||
| 378 | 378 | * |
| 379 | 379 | * @return void |
| 380 | 380 | */ |
| 381 | - private static function update_approved_meta( $entry_id, $is_approved ) { |
|
| 381 | + private static function update_approved_meta($entry_id, $is_approved) { |
|
| 382 | 382 | |
| 383 | 383 | // update entry meta |
| 384 | - if( function_exists('gform_update_meta') ) { |
|
| 384 | + if (function_exists('gform_update_meta')) { |
|
| 385 | 385 | |
| 386 | - gform_update_meta( $entry_id, 'is_approved', $is_approved ); |
|
| 386 | + gform_update_meta($entry_id, 'is_approved', $is_approved); |
|
| 387 | 387 | |
| 388 | 388 | /** |
| 389 | 389 | * @action `gravityview/approve_entries/updated` Triggered when an entry approval is updated |
@@ -391,16 +391,16 @@ discard block |
||
| 391 | 391 | * @param int $entry_id ID of the Gravity Forms entry |
| 392 | 392 | * @param string $is_approved String whether entry is approved or not. `0` for not approved, `Approved` for approved. |
| 393 | 393 | */ |
| 394 | - do_action( 'gravityview/approve_entries/updated', $entry_id, $is_approved ); |
|
| 394 | + do_action('gravityview/approve_entries/updated', $entry_id, $is_approved); |
|
| 395 | 395 | |
| 396 | - if( empty( $is_approved ) ) { |
|
| 396 | + if (empty($is_approved)) { |
|
| 397 | 397 | |
| 398 | 398 | /** |
| 399 | 399 | * @action `gravityview/approve_entries/disapproved` Triggered when an entry is rejected |
| 400 | 400 | * @since 1.7.6.1 |
| 401 | 401 | * @param int $entry_id ID of the Gravity Forms entry |
| 402 | 402 | */ |
| 403 | - do_action( 'gravityview/approve_entries/disapproved', $entry_id ); |
|
| 403 | + do_action('gravityview/approve_entries/disapproved', $entry_id); |
|
| 404 | 404 | |
| 405 | 405 | } else { |
| 406 | 406 | |
@@ -409,13 +409,13 @@ discard block |
||
| 409 | 409 | * @since 1.7.6.1 |
| 410 | 410 | * @param int $entry_id ID of the Gravity Forms entry |
| 411 | 411 | */ |
| 412 | - do_action( 'gravityview/approve_entries/approved', $entry_id ); |
|
| 412 | + do_action('gravityview/approve_entries/approved', $entry_id); |
|
| 413 | 413 | |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | } else { |
| 417 | 417 | |
| 418 | - do_action('gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
| 418 | + do_action('gravityview_log_error', __METHOD__.' - `gform_update_meta` does not exist.'); |
|
| 419 | 419 | |
| 420 | 420 | } |
| 421 | 421 | } |
@@ -427,40 +427,40 @@ discard block |
||
| 427 | 427 | */ |
| 428 | 428 | public function ajax_update_approved() { |
| 429 | 429 | |
| 430 | - if( empty( $_POST['entry_id'] ) || empty( $_POST['form_id'] ) ) { |
|
| 430 | + if (empty($_POST['entry_id']) || empty($_POST['form_id'])) { |
|
| 431 | 431 | |
| 432 | - do_action( 'gravityview_log_error', __METHOD__ . ' entry_id or form_id are empty.', $_POST ); |
|
| 432 | + do_action('gravityview_log_error', __METHOD__.' entry_id or form_id are empty.', $_POST); |
|
| 433 | 433 | |
| 434 | 434 | $result = false; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - else if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxgfentries' ) ) { |
|
| 437 | + else if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxgfentries')) { |
|
| 438 | 438 | |
| 439 | - do_action( 'gravityview_log_error', __METHOD__ . ' Security check failed.', $_POST ); |
|
| 439 | + do_action('gravityview_log_error', __METHOD__.' Security check failed.', $_POST); |
|
| 440 | 440 | |
| 441 | 441 | $result = false; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - else if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $_POST['entry_id'] ) ) { |
|
| 444 | + else if (!GVCommon::has_cap('gravityview_moderate_entries', $_POST['entry_id'])) { |
|
| 445 | 445 | |
| 446 | - do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
|
| 446 | + do_action('gravityview_log_error', __METHOD__.' User does not have the `gravityview_moderate_entries` capability.'); |
|
| 447 | 447 | |
| 448 | 448 | $result = false; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | else { |
| 452 | 452 | |
| 453 | - $result = self::update_approved( $_POST['entry_id'], $_POST['approved'], $_POST['form_id'] ); |
|
| 453 | + $result = self::update_approved($_POST['entry_id'], $_POST['approved'], $_POST['form_id']); |
|
| 454 | 454 | |
| 455 | - if( is_wp_error( $result ) ) { |
|
| 455 | + if (is_wp_error($result)) { |
|
| 456 | 456 | /** @var WP_Error $result */ |
| 457 | - do_action( 'gravityview_log_error', __METHOD__ .' Error updating approval: ' . $result->get_error_message() ); |
|
| 457 | + do_action('gravityview_log_error', __METHOD__.' Error updating approval: '.$result->get_error_message()); |
|
| 458 | 458 | $result = false; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - exit( $result ); |
|
| 463 | + exit($result); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | |
@@ -472,30 +472,30 @@ discard block |
||
| 472 | 472 | * @param mixed $form GF Form or Form ID |
| 473 | 473 | * @return false|null|string Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set. |
| 474 | 474 | */ |
| 475 | - static public function get_approved_column( $form ) { |
|
| 475 | + static public function get_approved_column($form) { |
|
| 476 | 476 | |
| 477 | - if( empty( $form ) ) { |
|
| 477 | + if (empty($form)) { |
|
| 478 | 478 | return null; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - if( !is_array( $form ) ) { |
|
| 482 | - $form = GVCommon::get_form( $form ); |
|
| 481 | + if (!is_array($form)) { |
|
| 482 | + $form = GVCommon::get_form($form); |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - foreach( $form['fields'] as $key => $field ) { |
|
| 485 | + foreach ($form['fields'] as $key => $field) { |
|
| 486 | 486 | |
| 487 | - $field = (array) $field; |
|
| 487 | + $field = (array)$field; |
|
| 488 | 488 | |
| 489 | - if( !empty( $field['gravityview_approved'] ) ) { |
|
| 490 | - if( !empty($field['inputs'][0]['id']) ) { |
|
| 489 | + if (!empty($field['gravityview_approved'])) { |
|
| 490 | + if (!empty($field['inputs'][0]['id'])) { |
|
| 491 | 491 | return $field['inputs'][0]['id']; |
| 492 | 492 | } |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
| 496 | - if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
| 497 | - foreach ( $field['inputs'] as $key2 => $input ) { |
|
| 498 | - if ( strtolower( $input['label'] ) == 'approved' ) { |
|
| 496 | + if ('checkbox' == $field['type'] && isset($field['inputs']) && is_array($field['inputs'])) { |
|
| 497 | + foreach ($field['inputs'] as $key2 => $input) { |
|
| 498 | + if (strtolower($input['label']) == 'approved') { |
|
| 499 | 499 | return $input['id']; |
| 500 | 500 | } |
| 501 | 501 | } |
@@ -507,70 +507,70 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | |
| 509 | 509 | |
| 510 | - static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
| 510 | + static public function add_entry_approved_hidden_input($form_id, $field_id, $value, $entry, $query_string) { |
|
| 511 | 511 | |
| 512 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry['id'] ) ) { |
|
| 512 | + if (!GVCommon::has_cap('gravityview_moderate_entries', $entry['id'])) { |
|
| 513 | 513 | return; |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - if( empty( $entry['id'] ) ) { |
|
| 516 | + if (empty($entry['id'])) { |
|
| 517 | 517 | return; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - if( gform_get_meta( $entry['id'], 'is_approved' ) ) { |
|
| 521 | - echo '<input type="hidden" class="entry_approved" id="entry_approved_'. $entry['id'] .'" value="true" />'; |
|
| 520 | + if (gform_get_meta($entry['id'], 'is_approved')) { |
|
| 521 | + echo '<input type="hidden" class="entry_approved" id="entry_approved_'.$entry['id'].'" value="true" />'; |
|
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | |
| 526 | 526 | |
| 527 | 527 | |
| 528 | - function add_scripts_and_styles( $hook ) { |
|
| 528 | + function add_scripts_and_styles($hook) { |
|
| 529 | 529 | |
| 530 | - if( !class_exists( 'RGForms' ) ) { |
|
| 530 | + if (!class_exists('RGForms')) { |
|
| 531 | 531 | |
| 532 | - do_action( 'gravityview_log_error', 'GravityView_Admin_ApproveEntries[add_scripts_and_styles] RGForms does not exist.' ); |
|
| 532 | + do_action('gravityview_log_error', 'GravityView_Admin_ApproveEntries[add_scripts_and_styles] RGForms does not exist.'); |
|
| 533 | 533 | |
| 534 | 534 | return; |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | // enqueue styles & scripts gf_entries |
| 538 | 538 | // But only if we're on the main Entries page, not on reports pages |
| 539 | - if( RGForms::get_page() === 'entry_list' ) { |
|
| 539 | + if (RGForms::get_page() === 'entry_list') { |
|
| 540 | 540 | |
| 541 | 541 | $form_id = RGForms::get('id'); |
| 542 | 542 | |
| 543 | 543 | // If there are no forms identified, use the first form. That's how GF does it. |
| 544 | - if( empty( $form_id ) && class_exists('RGFormsModel') ) { |
|
| 544 | + if (empty($form_id) && class_exists('RGFormsModel')) { |
|
| 545 | 545 | $forms = gravityview_get_forms(); |
| 546 | - if( !empty( $forms ) ) { |
|
| 546 | + if (!empty($forms)) { |
|
| 547 | 547 | $form_id = $forms[0]['id']; |
| 548 | 548 | } |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - $approvedcolumn = self::get_approved_column( $form_id ); |
|
| 551 | + $approvedcolumn = self::get_approved_column($form_id); |
|
| 552 | 552 | |
| 553 | - wp_register_style( 'gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
| 554 | - wp_enqueue_style( 'gravityview_entries_list' ); |
|
| 553 | + wp_register_style('gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version); |
|
| 554 | + wp_enqueue_style('gravityview_entries_list'); |
|
| 555 | 555 | |
| 556 | 556 | $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
| 557 | 557 | |
| 558 | - wp_register_script( 'gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version ); |
|
| 559 | - wp_enqueue_script( 'gravityview_gf_entries_scripts' ); |
|
| 558 | + wp_register_script('gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list'.$script_debug.'.js', GRAVITYVIEW_FILE), array('jquery'), GravityView_Plugin::version); |
|
| 559 | + wp_enqueue_script('gravityview_gf_entries_scripts'); |
|
| 560 | 560 | |
| 561 | - wp_localize_script( 'gravityview_gf_entries_scripts', 'gvGlobals', array( |
|
| 562 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxgfentries'), |
|
| 561 | + wp_localize_script('gravityview_gf_entries_scripts', 'gvGlobals', array( |
|
| 562 | + 'nonce' => wp_create_nonce('gravityview_ajaxgfentries'), |
|
| 563 | 563 | 'form_id' => $form_id, |
| 564 | - 'show_column' => (int)$this->show_approve_entry_column( $form_id ), |
|
| 565 | - 'add_bulk_action' => (int)GVCommon::has_cap( 'gravityview_moderate_entries' ), |
|
| 566 | - 'label_approve' => __( 'Approve', 'gravityview' ) , |
|
| 567 | - 'label_disapprove' => __( 'Disapprove', 'gravityview' ), |
|
| 564 | + 'show_column' => (int)$this->show_approve_entry_column($form_id), |
|
| 565 | + 'add_bulk_action' => (int)GVCommon::has_cap('gravityview_moderate_entries'), |
|
| 566 | + 'label_approve' => __('Approve', 'gravityview'), |
|
| 567 | + 'label_disapprove' => __('Disapprove', 'gravityview'), |
|
| 568 | 568 | 'bulk_message' => $this->bulk_update_message, |
| 569 | - 'approve_title' => __( 'Entry not approved for directory viewing. Click to approve this entry.', 'gravityview'), |
|
| 570 | - 'unapprove_title' => __( 'Entry approved for directory viewing. Click to disapprove this entry.', 'gravityview'), |
|
| 571 | - 'column_title' => __( 'Show entry in directory view?', 'gravityview'), |
|
| 572 | - 'column_link' => esc_url( add_query_arg( array('sort' => $approvedcolumn) ) ), |
|
| 573 | - ) ); |
|
| 569 | + 'approve_title' => __('Entry not approved for directory viewing. Click to approve this entry.', 'gravityview'), |
|
| 570 | + 'unapprove_title' => __('Entry approved for directory viewing. Click to disapprove this entry.', 'gravityview'), |
|
| 571 | + 'column_title' => __('Show entry in directory view?', 'gravityview'), |
|
| 572 | + 'column_link' => esc_url(add_query_arg(array('sort' => $approvedcolumn))), |
|
| 573 | + )); |
|
| 574 | 574 | |
| 575 | 575 | } |
| 576 | 576 | |
@@ -585,22 +585,22 @@ discard block |
||
| 585 | 585 | * |
| 586 | 586 | * @return bool True: Show column; False: hide column |
| 587 | 587 | */ |
| 588 | - private function show_approve_entry_column( $form_id ) { |
|
| 588 | + private function show_approve_entry_column($form_id) { |
|
| 589 | 589 | |
| 590 | - $show_approve_column = GVCommon::has_cap( 'gravityview_moderate_entries' ); |
|
| 590 | + $show_approve_column = GVCommon::has_cap('gravityview_moderate_entries'); |
|
| 591 | 591 | |
| 592 | 592 | /** |
| 593 | 593 | * @filter `gravityview/approve_entries/hide-if-no-connections` Return true to hide reject/approve if there are no connected Views |
| 594 | 594 | * @since 1.7.2 |
| 595 | 595 | * @param boolean $hide_if_no_connections |
| 596 | 596 | */ |
| 597 | - $hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false ); |
|
| 597 | + $hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false); |
|
| 598 | 598 | |
| 599 | - if( $hide_if_no_connections ) { |
|
| 599 | + if ($hide_if_no_connections) { |
|
| 600 | 600 | |
| 601 | - $connected_views = gravityview_get_connected_views( $form_id ); |
|
| 601 | + $connected_views = gravityview_get_connected_views($form_id); |
|
| 602 | 602 | |
| 603 | - if( empty( $connected_views ) ) { |
|
| 603 | + if (empty($connected_views)) { |
|
| 604 | 604 | $show_approve_column = false; |
| 605 | 605 | } |
| 606 | 606 | } |
@@ -610,17 +610,17 @@ discard block |
||
| 610 | 610 | * @param boolean $show_approve_column Whether the column will be shown |
| 611 | 611 | * @param int $form_id The ID of the Gravity Forms form for which entries are being shown |
| 612 | 612 | */ |
| 613 | - $show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
| 613 | + $show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id); |
|
| 614 | 614 | |
| 615 | 615 | return $show_approve_column; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - function register_gform_noconflict_script( $scripts ) { |
|
| 618 | + function register_gform_noconflict_script($scripts) { |
|
| 619 | 619 | $scripts[] = 'gravityview_gf_entries_scripts'; |
| 620 | 620 | return $scripts; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - function register_gform_noconflict_style( $styles ) { |
|
| 623 | + function register_gform_noconflict_style($styles) { |
|
| 624 | 624 | $styles[] = 'gravityview_entries_list'; |
| 625 | 625 | return $styles; |
| 626 | 626 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | 328 | * Get HTML links relating to a connected form, like Edit, Entries, Settings, Preview |
| 329 | - * @param array|int $form_id Gravity Forms forms array, or the form ID |
|
| 329 | + * @param array|int $form Gravity Forms forms array, or the form ID |
|
| 330 | 330 | * @param boolean $include_form_link Whether to include the bold name of the form in the output |
| 331 | 331 | * @return string HTML links |
| 332 | 332 | */ |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | * $blacklist_field_types - contains the field types which are not proper to be shown in a directory. |
| 548 | 548 | * |
| 549 | 549 | * @access public |
| 550 | - * @param int $form_id Gravity Forms Form ID (default: '') |
|
| 550 | + * @param int $form Gravity Forms Form ID (default: '') |
|
| 551 | 551 | * @param string $context (default: 'single') |
| 552 | 552 | * @return void |
| 553 | 553 | */ |
@@ -592,6 +592,10 @@ discard block |
||
| 592 | 592 | $this->render_additional_fields( $form, $context ); |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | + /** |
|
| 596 | + * @param string $form |
|
| 597 | + * @param string $context |
|
| 598 | + */ |
|
| 595 | 599 | function render_additional_fields( $form, $context ) { |
| 596 | 600 | |
| 597 | 601 | /** |
@@ -790,6 +794,7 @@ discard block |
||
| 790 | 794 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
| 791 | 795 | * @param array $rows The layout structure: rows, columns and areas |
| 792 | 796 | * @param array $values Saved objects |
| 797 | + * @param string $template_id |
|
| 793 | 798 | * @return void |
| 794 | 799 | */ |
| 795 | 800 | function render_active_areas( $template_id, $type, $zone, $rows, $values ) { |
@@ -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 | |
@@ -22,40 +22,40 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | function __construct() { |
| 24 | 24 | |
| 25 | - add_action( 'save_post', array( $this, 'save_postdata' ) ); |
|
| 25 | + add_action('save_post', array($this, 'save_postdata')); |
|
| 26 | 26 | |
| 27 | 27 | // set the blacklist field types across the entire plugin |
| 28 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'default_field_blacklist' ), 10, 2 ); |
|
| 28 | + add_filter('gravityview_blacklist_field_types', array($this, 'default_field_blacklist'), 10, 2); |
|
| 29 | 29 | |
| 30 | 30 | // Tooltips |
| 31 | - add_filter( 'gform_tooltips', array( $this, 'tooltips') ); |
|
| 31 | + add_filter('gform_tooltips', array($this, 'tooltips')); |
|
| 32 | 32 | |
| 33 | 33 | // adding styles and scripts |
| 34 | - add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles'), 999 ); |
|
| 35 | - add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
| 36 | - add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
| 37 | - add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
| 38 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
| 39 | - |
|
| 40 | - add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas'), 10, 4 ); |
|
| 41 | - add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas'), 10, 3 ); |
|
| 42 | - add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields'), 10, 2 ); |
|
| 43 | - add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets') ); |
|
| 44 | - add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas'), 10, 5 ); |
|
| 34 | + add_action('admin_enqueue_scripts', array('GravityView_Admin_Views', 'add_scripts_and_styles'), 999); |
|
| 35 | + add_filter('gform_noconflict_styles', array($this, 'register_no_conflict')); |
|
| 36 | + add_filter('gform_noconflict_scripts', array($this, 'register_no_conflict')); |
|
| 37 | + add_filter('gravityview_noconflict_styles', array($this, 'register_no_conflict')); |
|
| 38 | + add_filter('gravityview_noconflict_scripts', array($this, 'register_no_conflict')); |
|
| 39 | + |
|
| 40 | + add_action('gravityview_render_directory_active_areas', array($this, 'render_directory_active_areas'), 10, 4); |
|
| 41 | + add_action('gravityview_render_widgets_active_areas', array($this, 'render_widgets_active_areas'), 10, 3); |
|
| 42 | + add_action('gravityview_render_available_fields', array($this, 'render_available_fields'), 10, 2); |
|
| 43 | + add_action('gravityview_render_available_widgets', array($this, 'render_available_widgets')); |
|
| 44 | + add_action('gravityview_render_active_areas', array($this, 'render_active_areas'), 10, 5); |
|
| 45 | 45 | |
| 46 | 46 | // @todo check if this hook is needed.. |
| 47 | 47 | //add_action( 'gravityview_render_field_options', array( $this, 'render_field_options'), 10, 9 ); |
| 48 | 48 | |
| 49 | 49 | // Add Connected Form column |
| 50 | - add_filter('manage_gravityview_posts_columns' , array( $this, 'add_post_type_columns' ) ); |
|
| 50 | + add_filter('manage_gravityview_posts_columns', array($this, 'add_post_type_columns')); |
|
| 51 | 51 | |
| 52 | - add_filter( 'gform_toolbar_menu', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 ); |
|
| 52 | + add_filter('gform_toolbar_menu', array('GravityView_Admin_Views', 'gform_toolbar_menu'), 10, 2); |
|
| 53 | 53 | |
| 54 | - add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content'), 10, 2 ); |
|
| 54 | + add_action('manage_gravityview_posts_custom_column', array($this, 'add_custom_column_content'), 10, 2); |
|
| 55 | 55 | |
| 56 | - add_action( 'restrict_manage_posts', array( $this, 'add_view_dropdown' ) ); |
|
| 56 | + add_action('restrict_manage_posts', array($this, 'add_view_dropdown')); |
|
| 57 | 57 | |
| 58 | - add_action( 'pre_get_posts', array( $this, 'filter_pre_get_posts_by_gravityview_form_id' ) ); |
|
| 58 | + add_action('pre_get_posts', array($this, 'filter_pre_get_posts_by_gravityview_form_id')); |
|
| 59 | 59 | |
| 60 | 60 | } |
| 61 | 61 | |
@@ -63,42 +63,42 @@ discard block |
||
| 63 | 63 | * @since 1.15 |
| 64 | 64 | * @param WP_Query $query |
| 65 | 65 | */ |
| 66 | - public function filter_pre_get_posts_by_gravityview_form_id( &$query ) { |
|
| 66 | + public function filter_pre_get_posts_by_gravityview_form_id(&$query) { |
|
| 67 | 67 | global $pagenow; |
| 68 | 68 | |
| 69 | - if ( !is_admin() ) { |
|
| 69 | + if (!is_admin()) { |
|
| 70 | 70 | return; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if( 'edit.php' !== $pagenow || ! rgget( 'gravityview_form_id' ) || ! isset( $query->query_vars[ 'post_type' ] ) ) { |
|
| 73 | + if ('edit.php' !== $pagenow || !rgget('gravityview_form_id') || !isset($query->query_vars['post_type'])) { |
|
| 74 | 74 | return; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if ( $query->query_vars[ 'post_type' ] == 'gravityview' ) { |
|
| 78 | - $query->set( 'meta_query', array( |
|
| 77 | + if ($query->query_vars['post_type'] == 'gravityview') { |
|
| 78 | + $query->set('meta_query', array( |
|
| 79 | 79 | array( |
| 80 | 80 | 'key' => '_gravityview_form_id', |
| 81 | - 'value' => rgget( 'gravityview_form_id' ), |
|
| 81 | + 'value' => rgget('gravityview_form_id'), |
|
| 82 | 82 | ) |
| 83 | - ) ); |
|
| 83 | + )); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | function add_view_dropdown() { |
| 88 | 88 | $current_screen = get_current_screen(); |
| 89 | 89 | |
| 90 | - if( 'gravityview' !== $current_screen->post_type ) { |
|
| 90 | + if ('gravityview' !== $current_screen->post_type) { |
|
| 91 | 91 | return; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $forms = gravityview_get_forms(); |
| 95 | - $current_form = rgget( 'gravityview_form_id' ); |
|
| 95 | + $current_form = rgget('gravityview_form_id'); |
|
| 96 | 96 | // If there are no forms to select, show no forms. |
| 97 | - if( !empty( $forms ) ) { ?> |
|
| 97 | + if (!empty($forms)) { ?> |
|
| 98 | 98 | <select name="gravityview_form_id" id="gravityview_form_id"> |
| 99 | - <option value="" <?php selected( '', $current_form, true ); ?>><?php esc_html_e( 'All forms', 'gravityview' ); ?></option> |
|
| 100 | - <?php foreach( $forms as $form ) { ?> |
|
| 101 | - <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option> |
|
| 99 | + <option value="" <?php selected('', $current_form, true); ?>><?php esc_html_e('All forms', 'gravityview'); ?></option> |
|
| 100 | + <?php foreach ($forms as $form) { ?> |
|
| 101 | + <option value="<?php echo $form['id']; ?>" <?php selected($form['id'], $current_form, true); ?>><?php echo esc_html($form['title']); ?></option> |
|
| 102 | 102 | <?php } ?> |
| 103 | 103 | </select> |
| 104 | 104 | <?php } |
@@ -109,18 +109,18 @@ discard block |
||
| 109 | 109 | * @deprecated since 1.2 |
| 110 | 110 | * Start using GravityView_Render_Settings::render_setting_row |
| 111 | 111 | */ |
| 112 | - public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) { |
|
| 113 | - _deprecated_function( 'GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row' ); |
|
| 114 | - GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name , $id ); |
|
| 112 | + public static function render_setting_row($key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s') { |
|
| 113 | + _deprecated_function('GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row'); |
|
| 114 | + GravityView_Render_Settings::render_setting_row($key, $current_settings, $override_input, $name, $id); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * @deprecated since 1.2 |
| 119 | 119 | * Start using GravityView_Render_Settings::render_field_option |
| 120 | 120 | */ |
| 121 | - public static function render_field_option( $name = '', $option, $curr_value = NULL ) { |
|
| 122 | - _deprecated_function( 'GravityView_Admin_Views::render_field_option', '1.1.7', 'GravityView_Render_Settings::render_field_option' ); |
|
| 123 | - return GravityView_Render_Settings::render_field_option( $name, $option, $curr_value ); |
|
| 121 | + public static function render_field_option($name = '', $option, $curr_value = NULL) { |
|
| 122 | + _deprecated_function('GravityView_Admin_Views::render_field_option', '1.1.7', 'GravityView_Render_Settings::render_field_option'); |
|
| 123 | + return GravityView_Render_Settings::render_field_option($name, $option, $curr_value); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -130,31 +130,31 @@ discard block |
||
| 130 | 130 | * @param int $id ID of the current Gravity form |
| 131 | 131 | * @return array Modified array |
| 132 | 132 | */ |
| 133 | - static function gform_toolbar_menu( $menu_items = array(), $id = NULL ) { |
|
| 133 | + static function gform_toolbar_menu($menu_items = array(), $id = NULL) { |
|
| 134 | 134 | |
| 135 | - $connected_views = gravityview_get_connected_views( $id ); |
|
| 135 | + $connected_views = gravityview_get_connected_views($id); |
|
| 136 | 136 | |
| 137 | - if( empty( $connected_views ) ) { |
|
| 137 | + if (empty($connected_views)) { |
|
| 138 | 138 | return $menu_items; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $sub_menu_items = array(); |
| 142 | - foreach ( (array)$connected_views as $view ) { |
|
| 142 | + foreach ((array)$connected_views as $view) { |
|
| 143 | 143 | |
| 144 | - if( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) { |
|
| 144 | + if (!GVCommon::has_cap('edit_gravityview', $view->ID)) { |
|
| 145 | 145 | continue; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $label = empty( $view->post_title ) ? sprintf( __('No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title; |
|
| 148 | + $label = empty($view->post_title) ? sprintf(__('No Title (View #%d)', 'gravityview'), $view->ID) : $view->post_title; |
|
| 149 | 149 | |
| 150 | 150 | $sub_menu_items[] = array( |
| 151 | - 'label' => esc_attr( $label ), |
|
| 152 | - 'url' => admin_url( 'post.php?action=edit&post='.$view->ID ), |
|
| 151 | + 'label' => esc_attr($label), |
|
| 152 | + 'url' => admin_url('post.php?action=edit&post='.$view->ID), |
|
| 153 | 153 | ); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // If there were no items added, then let's create the parent menu |
| 157 | - if( $sub_menu_items ) { |
|
| 157 | + if ($sub_menu_items) { |
|
| 158 | 158 | |
| 159 | 159 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
| 160 | 160 | $sub_menu_items[] = array( |
@@ -165,16 +165,16 @@ discard block |
||
| 165 | 165 | ); |
| 166 | 166 | |
| 167 | 167 | $menu_items['gravityview'] = array( |
| 168 | - 'label' => __( 'Connected Views', 'gravityview' ), |
|
| 168 | + 'label' => __('Connected Views', 'gravityview'), |
|
| 169 | 169 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
| 170 | - 'title' => __( 'GravityView Views using this form as a data source', 'gravityview' ), |
|
| 170 | + 'title' => __('GravityView Views using this form as a data source', 'gravityview'), |
|
| 171 | 171 | 'url' => '#', |
| 172 | 172 | 'onclick' => 'return false;', |
| 173 | 173 | 'menu_class' => 'gv_connected_forms gf_form_toolbar_settings', |
| 174 | - 'link_class' => ( 1 === 1 ? '' : 'gf_toolbar_disabled' ), |
|
| 174 | + 'link_class' => (1 === 1 ? '' : 'gf_toolbar_disabled'), |
|
| 175 | 175 | 'sub_menu_items' => $sub_menu_items, |
| 176 | 176 | 'priority' => 0, |
| 177 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
| 177 | + 'capabilities' => array('edit_gravityviews'), |
|
| 178 | 178 | ); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -189,16 +189,16 @@ discard block |
||
| 189 | 189 | * @access public |
| 190 | 190 | * @return array Default blacklist fields merged with existing blacklist fields |
| 191 | 191 | */ |
| 192 | - function default_field_blacklist( $array = array(), $context = NULL ) { |
|
| 192 | + function default_field_blacklist($array = array(), $context = NULL) { |
|
| 193 | 193 | |
| 194 | - $add = array( 'captcha', 'page' ); |
|
| 194 | + $add = array('captcha', 'page'); |
|
| 195 | 195 | |
| 196 | 196 | // Don't allowing editing the following values: |
| 197 | - if( $context === 'edit' ) { |
|
| 197 | + if ($context === 'edit') { |
|
| 198 | 198 | $add[] = 'post_id'; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - $return = array_merge( $array, $add ); |
|
| 201 | + $return = array_merge($array, $add); |
|
| 202 | 202 | |
| 203 | 203 | return $return; |
| 204 | 204 | } |
@@ -208,33 +208,33 @@ discard block |
||
| 208 | 208 | * @param array $tooltips Array of Gravity Forms tooltips |
| 209 | 209 | * @return array Modified tooltips array |
| 210 | 210 | */ |
| 211 | - public function tooltips( $tooltips = array() ) { |
|
| 211 | + public function tooltips($tooltips = array()) { |
|
| 212 | 212 | |
| 213 | 213 | $gv_tooltips = array(); |
| 214 | 214 | |
| 215 | 215 | // Generate tooltips for View settings |
| 216 | - $default_args = GravityView_View_Data::get_default_args( true ); |
|
| 216 | + $default_args = GravityView_View_Data::get_default_args(true); |
|
| 217 | 217 | |
| 218 | - foreach ( $default_args as $key => $arg ) { |
|
| 218 | + foreach ($default_args as $key => $arg) { |
|
| 219 | 219 | |
| 220 | 220 | // If an arg has `tooltip` defined, but it's false, don't display a tooltip |
| 221 | - if( isset( $arg['tooltip'] ) && empty( $arg['tooltip'] ) ) { continue; } |
|
| 221 | + if (isset($arg['tooltip']) && empty($arg['tooltip'])) { continue; } |
|
| 222 | 222 | |
| 223 | 223 | // By default, use `tooltip` if defined. |
| 224 | - $tooltip = empty( $arg['tooltip'] ) ? NULL : $arg['tooltip']; |
|
| 224 | + $tooltip = empty($arg['tooltip']) ? NULL : $arg['tooltip']; |
|
| 225 | 225 | |
| 226 | 226 | // Otherwise, use the description as a tooltip. |
| 227 | - if( empty( $tooltip ) && !empty( $arg['desc'] ) ) { |
|
| 227 | + if (empty($tooltip) && !empty($arg['desc'])) { |
|
| 228 | 228 | $tooltip = $arg['desc']; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // If there's no tooltip set, continue |
| 232 | - if( empty( $tooltip ) ) { |
|
| 232 | + if (empty($tooltip)) { |
|
| 233 | 233 | continue; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // Add the tooltip |
| 237 | - $gv_tooltips[ 'gv_'.$key ] = array( |
|
| 237 | + $gv_tooltips['gv_'.$key] = array( |
|
| 238 | 238 | 'title' => $arg['label'], |
| 239 | 239 | 'value' => $tooltip, |
| 240 | 240 | ); |
@@ -243,20 +243,20 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | $gv_tooltips['gv_css_merge_tags'] = array( |
| 245 | 245 | 'title' => __('CSS Merge Tags', 'gravityview'), |
| 246 | - 'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>' ) |
|
| 246 | + 'value' => sprintf(__('Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>') |
|
| 247 | 247 | ); |
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | 250 | * @filter `gravityview_tooltips` The tooltips GravityView adds to the Gravity Forms tooltip array |
| 251 | 251 | * @param array $gv_tooltips Associative array with unique keys containing array of `title` and `value` keys, as expected by `gform_tooltips` filter |
| 252 | 252 | */ |
| 253 | - $gv_tooltips = apply_filters( 'gravityview_tooltips', $gv_tooltips ); |
|
| 253 | + $gv_tooltips = apply_filters('gravityview_tooltips', $gv_tooltips); |
|
| 254 | 254 | |
| 255 | - foreach ( $gv_tooltips as $key => $tooltip ) { |
|
| 255 | + foreach ($gv_tooltips as $key => $tooltip) { |
|
| 256 | 256 | |
| 257 | - $title = empty( $tooltip['title'] ) ? '' : '<h6>'.esc_html( $tooltip['title'] ) .'</h6>'; |
|
| 257 | + $title = empty($tooltip['title']) ? '' : '<h6>'.esc_html($tooltip['title']).'</h6>'; |
|
| 258 | 258 | |
| 259 | - $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip['value'] ) ); |
|
| 259 | + $tooltips[$key] = $title.wpautop(esc_html($tooltip['value'])); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | return $tooltips; |
@@ -270,27 +270,27 @@ discard block |
||
| 270 | 270 | * |
| 271 | 271 | * @return void |
| 272 | 272 | */ |
| 273 | - public function add_custom_column_content( $column_name = NULL, $post_id ) { |
|
| 273 | + public function add_custom_column_content($column_name = NULL, $post_id) { |
|
| 274 | 274 | |
| 275 | 275 | $output = ''; |
| 276 | 276 | |
| 277 | - switch ( $column_name ) { |
|
| 277 | + switch ($column_name) { |
|
| 278 | 278 | case 'gv_template': |
| 279 | 279 | |
| 280 | - $template_id = gravityview_get_template_id( $post_id ); |
|
| 280 | + $template_id = gravityview_get_template_id($post_id); |
|
| 281 | 281 | |
| 282 | 282 | // All Views should have a connected form. If it doesn't, that's not right. |
| 283 | - if ( empty( $template_id ) ) { |
|
| 284 | - do_action( 'gravityview_log_error', sprintf( __METHOD__ . ' View ID %s does not have a connected template.', $post_id ) ); |
|
| 283 | + if (empty($template_id)) { |
|
| 284 | + do_action('gravityview_log_error', sprintf(__METHOD__.' View ID %s does not have a connected template.', $post_id)); |
|
| 285 | 285 | break; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $templates = gravityview_get_registered_templates(); |
| 289 | 289 | |
| 290 | - $template = isset( $templates[ $template_id ] ) ? $templates[ $template_id ] : false; |
|
| 290 | + $template = isset($templates[$template_id]) ? $templates[$template_id] : false; |
|
| 291 | 291 | |
| 292 | 292 | // Generate backup if label doesn't exist: `example_name` => `Example Name` |
| 293 | - $template_id_pretty = ucwords( implode( ' ', explode( '_', $template_id ) ) ); |
|
| 293 | + $template_id_pretty = ucwords(implode(' ', explode('_', $template_id))); |
|
| 294 | 294 | |
| 295 | 295 | $output = $template ? $template['label'] : $template_id_pretty; |
| 296 | 296 | |
@@ -298,24 +298,24 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | case 'gv_connected_form': |
| 300 | 300 | |
| 301 | - $form_id = gravityview_get_form_id( $post_id ); |
|
| 301 | + $form_id = gravityview_get_form_id($post_id); |
|
| 302 | 302 | |
| 303 | 303 | // All Views should have a connected form. If it doesn't, that's not right. |
| 304 | - if ( empty( $form_id ) ) { |
|
| 305 | - do_action( 'gravityview_log_error', sprintf( '[add_data_source_column_content] View ID %s does not have a connected GF form.', $post_id ) ); |
|
| 306 | - $output = __( 'Not connected.', 'gravityview' ); |
|
| 304 | + if (empty($form_id)) { |
|
| 305 | + do_action('gravityview_log_error', sprintf('[add_data_source_column_content] View ID %s does not have a connected GF form.', $post_id)); |
|
| 306 | + $output = __('Not connected.', 'gravityview'); |
|
| 307 | 307 | break; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - $form = gravityview_get_form( $form_id ); |
|
| 310 | + $form = gravityview_get_form($form_id); |
|
| 311 | 311 | |
| 312 | - if ( ! $form ) { |
|
| 313 | - do_action( 'gravityview_log_error', sprintf( '[add_data_source_column_content] Connected form not found: Form #%d', $form_id ) ); |
|
| 312 | + if (!$form) { |
|
| 313 | + do_action('gravityview_log_error', sprintf('[add_data_source_column_content] Connected form not found: Form #%d', $form_id)); |
|
| 314 | 314 | |
| 315 | - $output = __( 'The connected form can not be found; it may no longer exist.', 'gravityview' ); |
|
| 315 | + $output = __('The connected form can not be found; it may no longer exist.', 'gravityview'); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - $output = self::get_connected_form_links( $form ); |
|
| 318 | + $output = self::get_connected_form_links($form); |
|
| 319 | 319 | |
| 320 | 320 | break; |
| 321 | 321 | } |
@@ -330,47 +330,47 @@ discard block |
||
| 330 | 330 | * @param boolean $include_form_link Whether to include the bold name of the form in the output |
| 331 | 331 | * @return string HTML links |
| 332 | 332 | */ |
| 333 | - static public function get_connected_form_links( $form, $include_form_link = true ) { |
|
| 333 | + static public function get_connected_form_links($form, $include_form_link = true) { |
|
| 334 | 334 | |
| 335 | 335 | // Either the form is empty or the form ID is 0, not yet set. |
| 336 | - if( empty( $form ) ) { |
|
| 336 | + if (empty($form)) { |
|
| 337 | 337 | return ''; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | // The $form is passed as the form ID |
| 341 | - if( !is_array( $form ) ) { |
|
| 342 | - $form = gravityview_get_form( $form ); |
|
| 341 | + if (!is_array($form)) { |
|
| 342 | + $form = gravityview_get_form($form); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | $form_id = $form['id']; |
| 346 | 346 | $links = array(); |
| 347 | 347 | |
| 348 | - if( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) { |
|
| 349 | - $form_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $form_id ) ); |
|
| 350 | - $form_link = '<strong class="gv-form-title">'.gravityview_get_link( $form_url, $form['title'], 'class=row-title' ).'</strong>'; |
|
| 351 | - $links[] = '<span>'.gravityview_get_link( $form_url, __('Edit Form', 'gravityview') ).'</span>'; |
|
| 348 | + if (GVCommon::has_cap('gravityforms_edit_forms')) { |
|
| 349 | + $form_url = admin_url(sprintf('admin.php?page=gf_edit_forms&id=%d', $form_id)); |
|
| 350 | + $form_link = '<strong class="gv-form-title">'.gravityview_get_link($form_url, $form['title'], 'class=row-title').'</strong>'; |
|
| 351 | + $links[] = '<span>'.gravityview_get_link($form_url, __('Edit Form', 'gravityview')).'</span>'; |
|
| 352 | 352 | } else { |
| 353 | - $form_link = '<strong class="gv-form-title">'. esc_html( $form['title'] ). '</strong>'; |
|
| 353 | + $form_link = '<strong class="gv-form-title">'.esc_html($form['title']).'</strong>'; |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if( GVCommon::has_cap( 'gravityforms_view_entries' ) ) { |
|
| 357 | - $entries_url = admin_url( sprintf( 'admin.php?page=gf_entries&id=%d', $form_id ) ); |
|
| 358 | - $links[] = '<span>'.gravityview_get_link( $entries_url, __('Entries', 'gravityview') ).'</span>'; |
|
| 356 | + if (GVCommon::has_cap('gravityforms_view_entries')) { |
|
| 357 | + $entries_url = admin_url(sprintf('admin.php?page=gf_entries&id=%d', $form_id)); |
|
| 358 | + $links[] = '<span>'.gravityview_get_link($entries_url, __('Entries', 'gravityview')).'</span>'; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - if( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) { |
|
| 362 | - $settings_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&view=settings&id=%d', $form_id ) ); |
|
| 363 | - $links[] = '<span>'.gravityview_get_link( $settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview') ).'</span>'; |
|
| 361 | + if (GVCommon::has_cap(array('gravityforms_edit_settings', 'gravityview_view_settings'))) { |
|
| 362 | + $settings_url = admin_url(sprintf('admin.php?page=gf_edit_forms&view=settings&id=%d', $form_id)); |
|
| 363 | + $links[] = '<span>'.gravityview_get_link($settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview')).'</span>'; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if( GVCommon::has_cap( array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms") ) ) { |
|
| 367 | - $preview_url = site_url( sprintf( '?gf_page=preview&id=%d', $form_id ) ); |
|
| 368 | - $links[] = '<span>'.gravityview_get_link( $preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview') ).'</span>'; |
|
| 366 | + if (GVCommon::has_cap(array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms"))) { |
|
| 367 | + $preview_url = site_url(sprintf('?gf_page=preview&id=%d', $form_id)); |
|
| 368 | + $links[] = '<span>'.gravityview_get_link($preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview')).'</span>'; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | $output = ''; |
| 372 | 372 | |
| 373 | - if( !empty( $include_form_link ) ) { |
|
| 373 | + if (!empty($include_form_link)) { |
|
| 374 | 374 | $output .= $form_link; |
| 375 | 375 | } |
| 376 | 376 | |
@@ -380,9 +380,9 @@ discard block |
||
| 380 | 380 | * @param array $links Links to show |
| 381 | 381 | * @param array $form Gravity Forms form array |
| 382 | 382 | */ |
| 383 | - $links = apply_filters( 'gravityview_connected_form_links', $links, $form ); |
|
| 383 | + $links = apply_filters('gravityview_connected_form_links', $links, $form); |
|
| 384 | 384 | |
| 385 | - $output .= '<div class="row-actions">'. implode( ' | ', $links ) .'</div>'; |
|
| 385 | + $output .= '<div class="row-actions">'.implode(' | ', $links).'</div>'; |
|
| 386 | 386 | |
| 387 | 387 | return $output; |
| 388 | 388 | } |
@@ -391,13 +391,13 @@ discard block |
||
| 391 | 391 | * Add the Data Source column to the Views page |
| 392 | 392 | * @param array $columns Columns array |
| 393 | 393 | */ |
| 394 | - public function add_post_type_columns( $columns ) { |
|
| 394 | + public function add_post_type_columns($columns) { |
|
| 395 | 395 | |
| 396 | 396 | // Get the date column and save it for later to add back in. |
| 397 | 397 | // This adds it after the Data Source column. |
| 398 | 398 | // This way, we don't need to do array_slice, array_merge, etc. |
| 399 | 399 | $date = $columns['date']; |
| 400 | - unset( $columns['date'] ); |
|
| 400 | + unset($columns['date']); |
|
| 401 | 401 | |
| 402 | 402 | $data_source_required_caps = array( |
| 403 | 403 | 'gravityforms_edit_forms', |
@@ -408,11 +408,11 @@ discard block |
||
| 408 | 408 | 'gravityforms_preview_forms', |
| 409 | 409 | ); |
| 410 | 410 | |
| 411 | - if( GVCommon::has_cap( $data_source_required_caps ) ) { |
|
| 412 | - $columns['gv_connected_form'] = __( 'Data Source', 'gravityview' ); |
|
| 411 | + if (GVCommon::has_cap($data_source_required_caps)) { |
|
| 412 | + $columns['gv_connected_form'] = __('Data Source', 'gravityview'); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - $columns['gv_template'] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' ); |
|
| 415 | + $columns['gv_template'] = _x('Template', 'Column title that shows what template is being used for Views', 'gravityview'); |
|
| 416 | 416 | |
| 417 | 417 | // Add the date back in. |
| 418 | 418 | $columns['date'] = $date; |
@@ -427,91 +427,91 @@ discard block |
||
| 427 | 427 | * @param int $post_id Currently saved Post ID |
| 428 | 428 | * @return void |
| 429 | 429 | */ |
| 430 | - function save_postdata( $post_id ) { |
|
| 430 | + function save_postdata($post_id) { |
|
| 431 | 431 | |
| 432 | - if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){ |
|
| 432 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 433 | 433 | return; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | // validate post_type |
| 437 | - if ( ! isset( $_POST['post_type'] ) || 'gravityview' != $_POST['post_type'] ) { |
|
| 437 | + if (!isset($_POST['post_type']) || 'gravityview' != $_POST['post_type']) { |
|
| 438 | 438 | return; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | // validate user can edit and save View |
| 442 | - if ( ! GVCommon::has_cap( 'edit_gravityview', $post_id ) ) { |
|
| 443 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Current user does not have the capability to edit View #' . $post_id, wp_get_current_user() ); |
|
| 442 | + if (!GVCommon::has_cap('edit_gravityview', $post_id)) { |
|
| 443 | + do_action('gravityview_log_error', __METHOD__.' - Current user does not have the capability to edit View #'.$post_id, wp_get_current_user()); |
|
| 444 | 444 | return; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - do_action( 'gravityview_log_debug', '[save_postdata] Saving View post type.', $_POST ); |
|
| 447 | + do_action('gravityview_log_debug', '[save_postdata] Saving View post type.', $_POST); |
|
| 448 | 448 | |
| 449 | 449 | $statii = array(); |
| 450 | 450 | |
| 451 | 451 | // check if this is a start fresh View |
| 452 | - if ( isset( $_POST['gravityview_select_form_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_form_nonce'], 'gravityview_select_form' ) ) { |
|
| 452 | + if (isset($_POST['gravityview_select_form_nonce']) && wp_verify_nonce($_POST['gravityview_select_form_nonce'], 'gravityview_select_form')) { |
|
| 453 | 453 | |
| 454 | - $form_id = !empty( $_POST['gravityview_form_id'] ) ? $_POST['gravityview_form_id'] : ''; |
|
| 454 | + $form_id = !empty($_POST['gravityview_form_id']) ? $_POST['gravityview_form_id'] : ''; |
|
| 455 | 455 | // save form id |
| 456 | - $statii['form_id'] = update_post_meta( $post_id, '_gravityview_form_id', $form_id ); |
|
| 456 | + $statii['form_id'] = update_post_meta($post_id, '_gravityview_form_id', $form_id); |
|
| 457 | 457 | |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii['form_id'] ) ) { |
|
| 461 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Current user does not have the capability to create a new Form.', wp_get_current_user() ); |
|
| 460 | + if (false === GVCommon::has_cap('gravityforms_create_form') && empty($statii['form_id'])) { |
|
| 461 | + do_action('gravityview_log_error', __METHOD__.' - Current user does not have the capability to create a new Form.', wp_get_current_user()); |
|
| 462 | 462 | return; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // Was this a start fresh? |
| 466 | - if ( ! empty( $_POST['gravityview_form_id_start_fresh'] ) ) { |
|
| 467 | - $statii['start_fresh'] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 ); |
|
| 466 | + if (!empty($_POST['gravityview_form_id_start_fresh'])) { |
|
| 467 | + $statii['start_fresh'] = add_post_meta($post_id, '_gravityview_start_fresh', 1); |
|
| 468 | 468 | } else { |
| 469 | - $statii['start_fresh'] = delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
| 469 | + $statii['start_fresh'] = delete_post_meta($post_id, '_gravityview_start_fresh'); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | // Check if we have a template id |
| 473 | - if ( isset( $_POST['gravityview_select_template_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_template_nonce'], 'gravityview_select_template' ) ) { |
|
| 473 | + if (isset($_POST['gravityview_select_template_nonce']) && wp_verify_nonce($_POST['gravityview_select_template_nonce'], 'gravityview_select_template')) { |
|
| 474 | 474 | |
| 475 | - $template_id = !empty( $_POST['gravityview_directory_template'] ) ? $_POST['gravityview_directory_template'] : ''; |
|
| 475 | + $template_id = !empty($_POST['gravityview_directory_template']) ? $_POST['gravityview_directory_template'] : ''; |
|
| 476 | 476 | |
| 477 | 477 | // now save template id |
| 478 | - $statii['directory_template'] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id ); |
|
| 478 | + $statii['directory_template'] = update_post_meta($post_id, '_gravityview_directory_template', $template_id); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | |
| 482 | 482 | // save View Configuration metabox |
| 483 | - if ( isset( $_POST['gravityview_view_configuration_nonce'] ) && wp_verify_nonce( $_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration' ) ) { |
|
| 483 | + if (isset($_POST['gravityview_view_configuration_nonce']) && wp_verify_nonce($_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration')) { |
|
| 484 | 484 | |
| 485 | 485 | // template settings |
| 486 | - if( empty( $_POST['template_settings'] ) ) { |
|
| 486 | + if (empty($_POST['template_settings'])) { |
|
| 487 | 487 | $_POST['template_settings'] = array(); |
| 488 | 488 | } |
| 489 | - $statii['template_settings'] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST['template_settings'] ); |
|
| 489 | + $statii['template_settings'] = update_post_meta($post_id, '_gravityview_template_settings', $_POST['template_settings']); |
|
| 490 | 490 | |
| 491 | 491 | $fields = array(); |
| 492 | 492 | |
| 493 | 493 | // Directory&single Visible Fields |
| 494 | - if( !empty( $preset_fields ) ) { |
|
| 494 | + if (!empty($preset_fields)) { |
|
| 495 | 495 | |
| 496 | 496 | $fields = $preset_fields; |
| 497 | 497 | |
| 498 | - } elseif( !empty( $_POST['fields'] ) ) { |
|
| 498 | + } elseif (!empty($_POST['fields'])) { |
|
| 499 | 499 | |
| 500 | - if( !is_array( $_POST['fields'] ) ) { |
|
| 500 | + if (!is_array($_POST['fields'])) { |
|
| 501 | 501 | |
| 502 | 502 | // Fields are passed as a jQuery-serialized array, created in admin-views.js in the serializeForm method |
| 503 | 503 | // Not using parse_str due to max_input_vars limitation |
| 504 | 504 | $fields_holder = array(); |
| 505 | - GVCommon::gv_parse_str( $_POST['fields'], $fields_holder ); |
|
| 505 | + GVCommon::gv_parse_str($_POST['fields'], $fields_holder); |
|
| 506 | 506 | |
| 507 | - if( isset( $fields_holder['fields'] ) ) { |
|
| 507 | + if (isset($fields_holder['fields'])) { |
|
| 508 | 508 | |
| 509 | 509 | // When parsed, there's a m |
| 510 | 510 | $fields = $fields_holder['fields']; |
| 511 | 511 | |
| 512 | 512 | } else { |
| 513 | 513 | |
| 514 | - do_action('gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder ); |
|
| 514 | + do_action('gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder); |
|
| 515 | 515 | |
| 516 | 516 | } |
| 517 | 517 | |
@@ -522,24 +522,24 @@ discard block |
||
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - $statii['directory_fields'] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields ); |
|
| 525 | + $statii['directory_fields'] = update_post_meta($post_id, '_gravityview_directory_fields', $fields); |
|
| 526 | 526 | |
| 527 | 527 | // Directory Visible Widgets |
| 528 | - if( empty( $_POST['widgets'] ) ) { |
|
| 528 | + if (empty($_POST['widgets'])) { |
|
| 529 | 529 | $_POST['widgets'] = array(); |
| 530 | 530 | } |
| 531 | - $statii['directory_widgets'] = update_post_meta( $post_id, '_gravityview_directory_widgets', $_POST['widgets'] ); |
|
| 531 | + $statii['directory_widgets'] = update_post_meta($post_id, '_gravityview_directory_widgets', $_POST['widgets']); |
|
| 532 | 532 | |
| 533 | 533 | } // end save view configuration |
| 534 | 534 | |
| 535 | - do_action('gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map( 'intval', $statii ) ); |
|
| 535 | + do_action('gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map('intval', $statii)); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
| 539 | 539 | * @deprecated 1.1.6 |
| 540 | 540 | */ |
| 541 | 541 | function render_label() { |
| 542 | - _deprecated_function( 'GravityView_Admin_Views::render_label()', '1.1.6', 'Use the GravityView_Admin_View_Field class instead.' ); |
|
| 542 | + _deprecated_function('GravityView_Admin_Views::render_label()', '1.1.6', 'Use the GravityView_Admin_View_Field class instead.'); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
@@ -551,33 +551,33 @@ discard block |
||
| 551 | 551 | * @param string $context (default: 'single') |
| 552 | 552 | * @return void |
| 553 | 553 | */ |
| 554 | - function render_available_fields( $form = '', $context = 'single' ) { |
|
| 554 | + function render_available_fields($form = '', $context = 'single') { |
|
| 555 | 555 | |
| 556 | 556 | /** |
| 557 | 557 | * @filter `gravityview_blacklist_field_types` Modify the types of fields that shouldn't be shown in a View. |
| 558 | 558 | * @param[in,out] array $blacklist_field_types Array of field types to block for this context. |
| 559 | 559 | * @param[in] string $context View context ('single', 'directory', or 'edit') |
| 560 | 560 | */ |
| 561 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array(), $context ); |
|
| 561 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array(), $context); |
|
| 562 | 562 | |
| 563 | - $fields = $this->get_available_fields( $form, $context ); |
|
| 563 | + $fields = $this->get_available_fields($form, $context); |
|
| 564 | 564 | |
| 565 | 565 | $output = ''; |
| 566 | 566 | |
| 567 | - if( !empty( $fields ) ) { |
|
| 567 | + if (!empty($fields)) { |
|
| 568 | 568 | |
| 569 | - foreach( $fields as $id => $details ) { |
|
| 569 | + foreach ($fields as $id => $details) { |
|
| 570 | 570 | |
| 571 | - if( in_array( $details['type'], $blacklist_field_types ) ) { |
|
| 571 | + if (in_array($details['type'], $blacklist_field_types)) { |
|
| 572 | 572 | continue; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | // Edit mode only allows editing the parent fields, not single inputs. |
| 576 | - if( $context === 'edit' && !empty( $details['parent'] ) ) { |
|
| 576 | + if ($context === 'edit' && !empty($details['parent'])) { |
|
| 577 | 577 | continue; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - $output .= new GravityView_Admin_View_Field( $details['label'], $id, $details ); |
|
| 580 | + $output .= new GravityView_Admin_View_Field($details['label'], $id, $details); |
|
| 581 | 581 | |
| 582 | 582 | } // End foreach |
| 583 | 583 | } |
@@ -585,22 +585,22 @@ discard block |
||
| 585 | 585 | echo $output; |
| 586 | 586 | |
| 587 | 587 | // For the EDIT view we only want to allow the form fields. |
| 588 | - if( $context === 'edit' ) { |
|
| 588 | + if ($context === 'edit') { |
|
| 589 | 589 | return; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - $this->render_additional_fields( $form, $context ); |
|
| 592 | + $this->render_additional_fields($form, $context); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - function render_additional_fields( $form, $context ) { |
|
| 595 | + function render_additional_fields($form, $context) { |
|
| 596 | 596 | |
| 597 | 597 | /** |
| 598 | 598 | * @filter `gravityview_additional_fields` non-standard Fields to show at the bottom of the field picker |
| 599 | 599 | * @param array $additional_fields Associative array of field arrays, with `label_text`, `desc`, `field_id`, `label_type`, `input_type`, `field_options`, and `settings_html` keys |
| 600 | 600 | */ |
| 601 | - $additional_fields = apply_filters( 'gravityview_additional_fields', array( |
|
| 601 | + $additional_fields = apply_filters('gravityview_additional_fields', array( |
|
| 602 | 602 | array( |
| 603 | - 'label_text' => __( '+ Add All Fields', 'gravityview' ), |
|
| 603 | + 'label_text' => __('+ Add All Fields', 'gravityview'), |
|
| 604 | 604 | 'desc' => __('Add all the available fields at once.', 'gravityview'), |
| 605 | 605 | 'field_id' => 'all-fields', |
| 606 | 606 | 'label_type' => 'field', |
@@ -610,11 +610,11 @@ discard block |
||
| 610 | 610 | ) |
| 611 | 611 | )); |
| 612 | 612 | |
| 613 | - if( !empty( $additional_fields )) { |
|
| 614 | - foreach ( (array)$additional_fields as $item ) { |
|
| 613 | + if (!empty($additional_fields)) { |
|
| 614 | + foreach ((array)$additional_fields as $item) { |
|
| 615 | 615 | |
| 616 | 616 | // Prevent items from not having index set |
| 617 | - $item = wp_parse_args( $item, array( |
|
| 617 | + $item = wp_parse_args($item, array( |
|
| 618 | 618 | 'label_text' => NULL, |
| 619 | 619 | 'field_id' => NULL, |
| 620 | 620 | 'label_type' => NULL, |
@@ -624,13 +624,13 @@ discard block |
||
| 624 | 624 | )); |
| 625 | 625 | |
| 626 | 626 | // Backward compat. |
| 627 | - if( !empty( $item['field_options'] ) ) { |
|
| 627 | + if (!empty($item['field_options'])) { |
|
| 628 | 628 | // Use settings_html from now on. |
| 629 | 629 | $item['settings_html'] = $item['field_options']; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // Render a label for each of them |
| 633 | - echo new GravityView_Admin_View_Field( $item['label_text'], $item['field_id'], $item ); |
|
| 633 | + echo new GravityView_Admin_View_Field($item['label_text'], $item['field_id'], $item); |
|
| 634 | 634 | |
| 635 | 635 | } |
| 636 | 636 | } |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | |
| 648 | 648 | $entry_default_fields = array(); |
| 649 | 649 | |
| 650 | - if( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
| 650 | + if (in_array($zone, array('directory', 'single'))) { |
|
| 651 | 651 | |
| 652 | 652 | $entry_default_fields = array( |
| 653 | 653 | 'id' => array( |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | ); |
| 697 | 697 | |
| 698 | 698 | |
| 699 | - if( 'single' !== $zone) { |
|
| 699 | + if ('single' !== $zone) { |
|
| 700 | 700 | |
| 701 | 701 | $entry_default_fields['entry_link'] = array( |
| 702 | 702 | 'label' => __('Link to Entry', 'gravityview'), |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | * @param string|array $form form_ID or form object |
| 715 | 715 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
| 716 | 716 | */ |
| 717 | - return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
| 717 | + return apply_filters('gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | /** |
@@ -723,25 +723,25 @@ discard block |
||
| 723 | 723 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
| 724 | 724 | * @return array fields |
| 725 | 725 | */ |
| 726 | - function get_available_fields( $form = '', $zone = NULL ) { |
|
| 726 | + function get_available_fields($form = '', $zone = NULL) { |
|
| 727 | 727 | |
| 728 | - if( empty( $form ) ) { |
|
| 729 | - do_action( 'gravityview_log_error', '[get_available_fields] $form is empty' ); |
|
| 728 | + if (empty($form)) { |
|
| 729 | + do_action('gravityview_log_error', '[get_available_fields] $form is empty'); |
|
| 730 | 730 | return array(); |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | // get form fields |
| 734 | - $fields = gravityview_get_form_fields( $form, true ); |
|
| 734 | + $fields = gravityview_get_form_fields($form, true); |
|
| 735 | 735 | |
| 736 | 736 | // get meta fields ( only if form was already created ) |
| 737 | - if( !is_array( $form ) ) { |
|
| 738 | - $meta_fields = gravityview_get_entry_meta( $form ); |
|
| 737 | + if (!is_array($form)) { |
|
| 738 | + $meta_fields = gravityview_get_entry_meta($form); |
|
| 739 | 739 | } else { |
| 740 | 740 | $meta_fields = array(); |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | // get default fields |
| 744 | - $default_fields = $this->get_entry_default_fields( $form, $zone ); |
|
| 744 | + $default_fields = $this->get_entry_default_fields($form, $zone); |
|
| 745 | 745 | |
| 746 | 746 | //merge without loosing the keys |
| 747 | 747 | $fields = $fields + $meta_fields + $default_fields; |
@@ -758,11 +758,11 @@ discard block |
||
| 758 | 758 | |
| 759 | 759 | $widgets = $this->get_registered_widgets(); |
| 760 | 760 | |
| 761 | - if( !empty( $widgets ) ) { |
|
| 761 | + if (!empty($widgets)) { |
|
| 762 | 762 | |
| 763 | - foreach( $widgets as $id => $details ) { |
|
| 763 | + foreach ($widgets as $id => $details) { |
|
| 764 | 764 | |
| 765 | - echo new GravityView_Admin_View_Widget( $details['label'], $id, $details ); |
|
| 765 | + echo new GravityView_Admin_View_Widget($details['label'], $id, $details); |
|
| 766 | 766 | |
| 767 | 767 | } |
| 768 | 768 | } |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | * @filter `gravityview_register_directory_widgets` Get the list of registered widgets. Each item is used to instantiate a GravityView_Admin_View_Widget object |
| 780 | 780 | * @param array $registered_widgets Empty array |
| 781 | 781 | */ |
| 782 | - $registered_widgets = apply_filters( 'gravityview_register_directory_widgets', array() ); |
|
| 782 | + $registered_widgets = apply_filters('gravityview_register_directory_widgets', array()); |
|
| 783 | 783 | |
| 784 | 784 | return $registered_widgets; |
| 785 | 785 | } |
@@ -792,67 +792,67 @@ discard block |
||
| 792 | 792 | * @param array $values Saved objects |
| 793 | 793 | * @return void |
| 794 | 794 | */ |
| 795 | - function render_active_areas( $template_id, $type, $zone, $rows, $values ) { |
|
| 795 | + function render_active_areas($template_id, $type, $zone, $rows, $values) { |
|
| 796 | 796 | global $post; |
| 797 | 797 | |
| 798 | - if( $type === 'widget' ) { |
|
| 799 | - $button_label = __( 'Add Widget', 'gravityview' ); |
|
| 798 | + if ($type === 'widget') { |
|
| 799 | + $button_label = __('Add Widget', 'gravityview'); |
|
| 800 | 800 | } else { |
| 801 | - $button_label = __( 'Add Field', 'gravityview' ); |
|
| 801 | + $button_label = __('Add Field', 'gravityview'); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | $available_items = array(); |
| 805 | 805 | |
| 806 | 806 | // if saved values, get available fields to label everyone |
| 807 | - if( !empty( $values ) && ( !empty( $post->ID ) || !empty( $_POST['template_id'] ) ) ) { |
|
| 807 | + if (!empty($values) && (!empty($post->ID) || !empty($_POST['template_id']))) { |
|
| 808 | 808 | |
| 809 | - if( !empty( $_POST['template_id'] ) ) { |
|
| 810 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 809 | + if (!empty($_POST['template_id'])) { |
|
| 810 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
| 811 | 811 | } else { |
| 812 | - $form = gravityview_get_form_id( $post->ID ); |
|
| 812 | + $form = gravityview_get_form_id($post->ID); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - if( 'field' === $type ) { |
|
| 816 | - $available_items = $this->get_available_fields( $form, $zone ); |
|
| 815 | + if ('field' === $type) { |
|
| 816 | + $available_items = $this->get_available_fields($form, $zone); |
|
| 817 | 817 | } else { |
| 818 | 818 | $available_items = $this->get_registered_widgets(); |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | - foreach( $rows as $row ) : |
|
| 824 | - foreach( $row as $col => $areas ) : |
|
| 823 | + foreach ($rows as $row) : |
|
| 824 | + foreach ($row as $col => $areas) : |
|
| 825 | 825 | $column = ($col == '2-2') ? '1-2' : $col; ?> |
| 826 | 826 | |
| 827 | - <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
|
| 827 | + <div class="gv-grid-col-<?php echo esc_attr($column); ?>"> |
|
| 828 | 828 | |
| 829 | - <?php foreach( $areas as $area ) : ?> |
|
| 829 | + <?php foreach ($areas as $area) : ?> |
|
| 830 | 830 | |
| 831 | 831 | <div class="gv-droppable-area"> |
| 832 | - <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>"> |
|
| 832 | + <div class="active-drop active-drop-<?php echo esc_attr($type); ?>" data-areaid="<?php echo esc_attr($zone.'_'.$area['areaid']); ?>"> |
|
| 833 | 833 | |
| 834 | 834 | <?php // render saved fields |
| 835 | 835 | |
| 836 | - if( !empty( $values[ $zone .'_'. $area['areaid'] ] ) ) { |
|
| 836 | + if (!empty($values[$zone.'_'.$area['areaid']])) { |
|
| 837 | 837 | |
| 838 | - foreach( $values[ $zone .'_'. $area['areaid'] ] as $uniqid => $field ) { |
|
| 838 | + foreach ($values[$zone.'_'.$area['areaid']] as $uniqid => $field) { |
|
| 839 | 839 | |
| 840 | 840 | $input_type = NULL; |
| 841 | - $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
|
| 841 | + $original_item = isset($available_items[$field['id']]) ? $available_items[$field['id']] : false; |
|
| 842 | 842 | |
| 843 | - if( !$original_item ) { |
|
| 843 | + if (!$original_item) { |
|
| 844 | 844 | |
| 845 | - do_action('gravityview_log_error', 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array('available_items' => $available_items, 'field' => $field )); |
|
| 845 | + do_action('gravityview_log_error', 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array('available_items' => $available_items, 'field' => $field)); |
|
| 846 | 846 | |
| 847 | 847 | $original_item = $field; |
| 848 | 848 | } else { |
| 849 | 849 | |
| 850 | - $input_type = isset( $original_item['type'] ) ? $original_item['type'] : NULL; |
|
| 850 | + $input_type = isset($original_item['type']) ? $original_item['type'] : NULL; |
|
| 851 | 851 | |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | // Field options dialog box |
| 855 | - $field_options = GravityView_Render_Settings::render_field_options( $type, $template_id, $field['id'], $original_item['label'], $zone .'_'. $area['areaid'], $input_type, $uniqid, $field, $zone, $original_item ); |
|
| 855 | + $field_options = GravityView_Render_Settings::render_field_options($type, $template_id, $field['id'], $original_item['label'], $zone.'_'.$area['areaid'], $input_type, $uniqid, $field, $zone, $original_item); |
|
| 856 | 856 | |
| 857 | 857 | $item = array( |
| 858 | 858 | 'input_type' => $input_type, |
@@ -861,16 +861,16 @@ discard block |
||
| 861 | 861 | ); |
| 862 | 862 | |
| 863 | 863 | // Merge the values with the current item to pass things like widget descriptions and original field names |
| 864 | - if( $original_item ) { |
|
| 865 | - $item = wp_parse_args( $item, $original_item ); |
|
| 864 | + if ($original_item) { |
|
| 865 | + $item = wp_parse_args($item, $original_item); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | - switch( $type ) { |
|
| 868 | + switch ($type) { |
|
| 869 | 869 | case 'widget': |
| 870 | - echo new GravityView_Admin_View_Widget( $item['label'], $field['id'], $item, $field ); |
|
| 870 | + echo new GravityView_Admin_View_Widget($item['label'], $field['id'], $item, $field); |
|
| 871 | 871 | break; |
| 872 | 872 | default: |
| 873 | - echo new GravityView_Admin_View_Field( $item['label'], $field['id'], $item, $field ); |
|
| 873 | + echo new GravityView_Admin_View_Field($item['label'], $field['id'], $item, $field); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | |
@@ -880,11 +880,11 @@ discard block |
||
| 880 | 880 | |
| 881 | 881 | } // End if zone is not empty ?> |
| 882 | 882 | |
| 883 | - <span class="drop-message"><?php echo sprintf(esc_attr__('"+ %s" or drag existing %ss here.', 'gravityview'), $button_label, $type ); ?></span> |
|
| 883 | + <span class="drop-message"><?php echo sprintf(esc_attr__('"+ %s" or drag existing %ss here.', 'gravityview'), $button_label, $type); ?></span> |
|
| 884 | 884 | </div> |
| 885 | 885 | <div class="gv-droppable-area-action"> |
| 886 | - <a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"><?php echo '+ '.esc_html( $button_label ); ?></a> |
|
| 887 | - <p class="gv-droppable-area-title"><strong><?php echo esc_html( $area['title'] ); ?></strong><?php if( !empty( $area['subtitle'] ) ) { ?><span class="gv-droppable-area-subtitle"> – <?php echo esc_html( $area['subtitle'] ); ?></span><?php } ?></p> |
|
| 886 | + <a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr($type); ?>" data-areaid="<?php echo esc_attr($zone.'_'.$area['areaid']); ?>" data-context="<?php echo esc_attr($zone); ?>"><?php echo '+ '.esc_html($button_label); ?></a> |
|
| 887 | + <p class="gv-droppable-area-title"><strong><?php echo esc_html($area['title']); ?></strong><?php if (!empty($area['subtitle'])) { ?><span class="gv-droppable-area-subtitle"> – <?php echo esc_html($area['subtitle']); ?></span><?php } ?></p> |
|
| 888 | 888 | </div> |
| 889 | 889 | </div> |
| 890 | 890 | |
@@ -901,13 +901,13 @@ discard block |
||
| 901 | 901 | * @param string $post_id Current Post ID (view) |
| 902 | 902 | * @return string html |
| 903 | 903 | */ |
| 904 | - function render_widgets_active_areas( $template_id = '', $zone, $post_id = '' ) { |
|
| 904 | + function render_widgets_active_areas($template_id = '', $zone, $post_id = '') { |
|
| 905 | 905 | |
| 906 | 906 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
| 907 | 907 | |
| 908 | 908 | $widgets = array(); |
| 909 | - if( !empty( $post_id ) ) { |
|
| 910 | - $widgets = get_post_meta( $post_id, '_gravityview_directory_widgets', true ); |
|
| 909 | + if (!empty($post_id)) { |
|
| 910 | + $widgets = get_post_meta($post_id, '_gravityview_directory_widgets', true); |
|
| 911 | 911 | |
| 912 | 912 | } |
| 913 | 913 | |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | ?> |
| 916 | 916 | |
| 917 | 917 | <div class="gv-grid gv-grid-pad gv-grid-border" id="directory-<?php echo $zone; ?>-widgets"> |
| 918 | - <?php $this->render_active_areas( $template_id, 'widget', $zone, $default_widget_areas, $widgets ); ?> |
|
| 918 | + <?php $this->render_active_areas($template_id, 'widget', $zone, $default_widget_areas, $widgets); ?> |
|
| 919 | 919 | </div> |
| 920 | 920 | |
| 921 | 921 | <?php |
@@ -935,36 +935,36 @@ discard block |
||
| 935 | 935 | * @param string $context (default: 'single') |
| 936 | 936 | * @return string HTML of the active areas |
| 937 | 937 | */ |
| 938 | - function render_directory_active_areas( $template_id = '', $context = 'single', $post_id = '', $echo = false ) { |
|
| 938 | + function render_directory_active_areas($template_id = '', $context = 'single', $post_id = '', $echo = false) { |
|
| 939 | 939 | |
| 940 | - if( empty( $template_id ) ) { |
|
| 941 | - do_action( 'gravityview_log_debug', '[render_directory_active_areas] $template_id is empty' ); |
|
| 940 | + if (empty($template_id)) { |
|
| 941 | + do_action('gravityview_log_debug', '[render_directory_active_areas] $template_id is empty'); |
|
| 942 | 942 | return; |
| 943 | 943 | } |
| 944 | 944 | |
| 945 | - $template_areas = apply_filters( 'gravityview_template_active_areas', array(), $template_id, $context ); |
|
| 945 | + $template_areas = apply_filters('gravityview_template_active_areas', array(), $template_id, $context); |
|
| 946 | 946 | |
| 947 | - if( empty( $template_areas ) ) { |
|
| 947 | + if (empty($template_areas)) { |
|
| 948 | 948 | |
| 949 | - do_action( 'gravityview_log_debug', '[render_directory_active_areas] No areas defined. Maybe template %s is disabled.', $template_id ); |
|
| 949 | + do_action('gravityview_log_debug', '[render_directory_active_areas] No areas defined. Maybe template %s is disabled.', $template_id); |
|
| 950 | 950 | $output = '<div>'; |
| 951 | - $output .= '<h2 class="description" style="font-size: 16px; margin:0">'. sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>'.$template_id.'</em>' ) .'</h2>'; |
|
| 951 | + $output .= '<h2 class="description" style="font-size: 16px; margin:0">'.sprintf(esc_html__('This View is configured using the %s View type, which is disabled.', 'gravityview'), '<em>'.$template_id.'</em>').'</h2>'; |
|
| 952 | 952 | $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">'.esc_html__('The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview').'</p>'; |
| 953 | 953 | $output .= '</div>'; |
| 954 | 954 | } else { |
| 955 | 955 | |
| 956 | 956 | $fields = ''; |
| 957 | - if ( ! empty( $post_id ) ) { |
|
| 958 | - $fields = gravityview_get_directory_fields( $post_id ); |
|
| 957 | + if (!empty($post_id)) { |
|
| 958 | + $fields = gravityview_get_directory_fields($post_id); |
|
| 959 | 959 | } |
| 960 | 960 | |
| 961 | 961 | ob_start(); |
| 962 | - $this->render_active_areas( $template_id, 'field', $context, $template_areas, $fields ); |
|
| 962 | + $this->render_active_areas($template_id, 'field', $context, $template_areas, $fields); |
|
| 963 | 963 | $output = ob_get_clean(); |
| 964 | 964 | |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | - if( $echo ) { |
|
| 967 | + if ($echo) { |
|
| 968 | 968 | echo $output; |
| 969 | 969 | } |
| 970 | 970 | |
@@ -978,46 +978,46 @@ discard block |
||
| 978 | 978 | * @param mixed $hook |
| 979 | 979 | * @return void |
| 980 | 980 | */ |
| 981 | - static function add_scripts_and_styles( $hook ) { |
|
| 981 | + static function add_scripts_and_styles($hook) { |
|
| 982 | 982 | global $plugin_page, $pagenow; |
| 983 | 983 | |
| 984 | - $is_widgets_page = ( $pagenow === 'widgets.php' ); |
|
| 984 | + $is_widgets_page = ($pagenow === 'widgets.php'); |
|
| 985 | 985 | |
| 986 | 986 | // Add the GV font (with the Astronaut) |
| 987 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
| 987 | + wp_enqueue_style('gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version); |
|
| 988 | 988 | |
| 989 | - wp_register_script( 'gravityview-jquery-cookie', plugins_url('includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version, true ); |
|
| 989 | + wp_register_script('gravityview-jquery-cookie', plugins_url('includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE), array('jquery'), GravityView_Plugin::version, true); |
|
| 990 | 990 | |
| 991 | 991 | // Don't process any scripts below here if it's not a GravityView page. |
| 992 | - if( !gravityview_is_admin_page($hook) && !$is_widgets_page ) { return; } |
|
| 992 | + if (!gravityview_is_admin_page($hook) && !$is_widgets_page) { return; } |
|
| 993 | 993 | |
| 994 | 994 | // Only enqueue the following on single pages |
| 995 | - if( gravityview_is_admin_page($hook, 'single') || $is_widgets_page ) { |
|
| 995 | + if (gravityview_is_admin_page($hook, 'single') || $is_widgets_page) { |
|
| 996 | 996 | |
| 997 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 998 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
| 997 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 998 | + wp_enqueue_style('gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version); |
|
| 999 | 999 | |
| 1000 | 1000 | $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
| 1001 | 1001 | |
| 1002 | 1002 | //enqueue scripts |
| 1003 | - wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), GravityView_Plugin::version ); |
|
| 1003 | + wp_enqueue_script('gravityview_views_scripts', plugins_url('assets/js/admin-views'.$script_debug.'.js', GRAVITYVIEW_FILE), array('jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore'), GravityView_Plugin::version); |
|
| 1004 | 1004 | |
| 1005 | 1005 | wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
| 1006 | 1006 | 'cookiepath' => COOKIEPATH, |
| 1007 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
| 1008 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
| 1009 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
| 1010 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
| 1011 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
| 1012 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
| 1013 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
| 1014 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
| 1015 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
| 1016 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
| 1017 | - 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
|
| 1007 | + 'nonce' => wp_create_nonce('gravityview_ajaxviews'), |
|
| 1008 | + 'label_viewname' => __('Enter View name here', 'gravityview'), |
|
| 1009 | + 'label_close' => __('Close', 'gravityview'), |
|
| 1010 | + 'label_cancel' => __('Cancel', 'gravityview'), |
|
| 1011 | + 'label_continue' => __('Continue', 'gravityview'), |
|
| 1012 | + 'label_ok' => __('Ok', 'gravityview'), |
|
| 1013 | + 'label_publisherror' => __('Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview'), |
|
| 1014 | + 'loading_text' => esc_html__('Loading…', 'gravityview'), |
|
| 1015 | + 'loading_error' => esc_html__('There was an error loading dynamic content.', 'gravityview'), |
|
| 1016 | + 'field_loaderror' => __('Error while adding the field. Please try again or contact GravityView support.', 'gravityview'), |
|
| 1017 | + 'remove_all_fields' => __('Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview'), |
|
| 1018 | 1018 | )); |
| 1019 | 1019 | |
| 1020 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
| 1020 | + wp_enqueue_style('gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons', 'wp-jquery-ui-dialog'), GravityView_Plugin::version); |
|
| 1021 | 1021 | |
| 1022 | 1022 | self::enqueue_gravity_forms_scripts(); |
| 1023 | 1023 | |
@@ -1035,25 +1035,25 @@ discard block |
||
| 1035 | 1035 | 'jquery-ui-autocomplete' |
| 1036 | 1036 | ); |
| 1037 | 1037 | |
| 1038 | - if ( wp_is_mobile() ) |
|
| 1038 | + if (wp_is_mobile()) |
|
| 1039 | 1039 | $scripts[] = 'jquery-touch-punch'; |
| 1040 | 1040 | |
| 1041 | 1041 | foreach ($scripts as $script) { |
| 1042 | - wp_enqueue_script( $script ); |
|
| 1042 | + wp_enqueue_script($script); |
|
| 1043 | 1043 | } |
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | - function register_no_conflict( $registered ) { |
|
| 1046 | + function register_no_conflict($registered) { |
|
| 1047 | 1047 | |
| 1048 | 1048 | $filter = current_filter(); |
| 1049 | 1049 | |
| 1050 | - if( preg_match('/script/ism', $filter ) ) { |
|
| 1051 | - $allow_scripts = array( 'jquery-ui-core', 'jquery-ui-dialog', 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'gravityview_views_scripts', 'gravityview-support', 'gravityview-jquery-cookie', 'gravityview_views_datepicker', |
|
| 1052 | - 'sack', 'gform_gravityforms', 'gform_forms', 'gform_form_admin', 'jquery-ui-autocomplete' ); |
|
| 1053 | - $registered = array_merge( $registered, $allow_scripts ); |
|
| 1054 | - } elseif( preg_match('/style/ism', $filter ) ) { |
|
| 1055 | - $allow_styles = array( 'dashicons', 'wp-jquery-ui-dialog', 'gravityview_views_styles', 'gravityview_global', 'gravityview_views_datepicker' ); |
|
| 1056 | - $registered = array_merge( $registered, $allow_styles ); |
|
| 1050 | + if (preg_match('/script/ism', $filter)) { |
|
| 1051 | + $allow_scripts = array('jquery-ui-core', 'jquery-ui-dialog', 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'gravityview_views_scripts', 'gravityview-support', 'gravityview-jquery-cookie', 'gravityview_views_datepicker', |
|
| 1052 | + 'sack', 'gform_gravityforms', 'gform_forms', 'gform_form_admin', 'jquery-ui-autocomplete'); |
|
| 1053 | + $registered = array_merge($registered, $allow_scripts); |
|
| 1054 | + } elseif (preg_match('/style/ism', $filter)) { |
|
| 1055 | + $allow_styles = array('dashicons', 'wp-jquery-ui-dialog', 'gravityview_views_styles', 'gravityview_global', 'gravityview_views_datepicker'); |
|
| 1056 | + $registered = array_merge($registered, $allow_styles); |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | return $registered; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * Remove any style or script non-registered in the no conflict mode |
| 312 | 312 | * @todo Move this to GravityView_Admin_Views |
| 313 | 313 | * @param WP_Dependencies $wp_objects Object of WP_Styles or WP_Scripts |
| 314 | - * @param array $required_objects List of registered script/style handles |
|
| 314 | + * @param string[] $required_objects List of registered script/style handles |
|
| 315 | 315 | * @param string $type Either 'styles' or 'scripts' |
| 316 | 316 | * @return void |
| 317 | 317 | */ |
@@ -472,6 +472,9 @@ discard block |
||
| 472 | 472 | |
| 473 | 473 | new GravityView_Admin; |
| 474 | 474 | |
| 475 | +/** |
|
| 476 | + * @param string $page |
|
| 477 | + */ |
|
| 475 | 478 | function gravityview_is_admin_page($hook = '', $page = NULL) { |
| 476 | 479 | return GravityView_Admin::is_admin_page( $hook, $page ); |
| 477 | 480 | } |
@@ -4,10 +4,10 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | function __construct() { |
| 6 | 6 | |
| 7 | - if( ! is_admin() ) { return; } |
|
| 7 | + if (!is_admin()) { return; } |
|
| 8 | 8 | |
| 9 | 9 | // If Gravity Forms isn't active or compatibile, stop loading |
| 10 | - if( false === GravityView_Compatibility::is_valid() ) { |
|
| 10 | + if (false === GravityView_Compatibility::is_valid()) { |
|
| 11 | 11 | return; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -22,22 +22,22 @@ discard block |
||
| 22 | 22 | private function include_required_files() { |
| 23 | 23 | |
| 24 | 24 | // Migrate Class |
| 25 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-migrate.php' ); |
|
| 25 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-migrate.php'); |
|
| 26 | 26 | |
| 27 | 27 | // Don't load tooltips if on Gravity Forms, otherwise it overrides translations |
| 28 | - if( class_exists( 'GFCommon' ) && class_exists( 'GFForms' ) && !GFForms::is_gravity_page() ) { |
|
| 29 | - require_once( GFCommon::get_base_path() . '/tooltips.php' ); |
|
| 28 | + if (class_exists('GFCommon') && class_exists('GFForms') && !GFForms::is_gravity_page()) { |
|
| 29 | + require_once(GFCommon::get_base_path().'/tooltips.php'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php' ); |
|
| 33 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/entry-list.php' ); |
|
| 34 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' ); |
|
| 32 | + require_once(GRAVITYVIEW_DIR.'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php'); |
|
| 33 | + require_once(GRAVITYVIEW_DIR.'includes/admin/entry-list.php'); |
|
| 34 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-change-entry-creator.php'); |
|
| 35 | 35 | |
| 36 | 36 | /** @since 1.15 **/ |
| 37 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-support-port.php' ); |
|
| 37 | + require_once(GRAVITYVIEW_DIR.'includes/admin/class-gravityview-support-port.php'); |
|
| 38 | 38 | |
| 39 | 39 | /** @since 1.6 */ |
| 40 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-duplicate-view.php' ); |
|
| 40 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-admin-duplicate-view.php'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -47,21 +47,21 @@ discard block |
||
| 47 | 47 | private function add_hooks() { |
| 48 | 48 | |
| 49 | 49 | // Filter Admin messages |
| 50 | - add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) ); |
|
| 51 | - add_filter( 'bulk_post_updated_messages', array( $this, 'post_updated_messages' ) ); |
|
| 50 | + add_filter('post_updated_messages', array($this, 'post_updated_messages')); |
|
| 51 | + add_filter('bulk_post_updated_messages', array($this, 'post_updated_messages')); |
|
| 52 | 52 | |
| 53 | - add_filter( 'plugin_action_links_'. plugin_basename( GRAVITYVIEW_FILE ) , array( $this, 'plugin_action_links' ) ); |
|
| 53 | + add_filter('plugin_action_links_'.plugin_basename(GRAVITYVIEW_FILE), array($this, 'plugin_action_links')); |
|
| 54 | 54 | |
| 55 | - add_action( 'plugins_loaded', array( $this, 'backend_actions' ), 100 ); |
|
| 55 | + add_action('plugins_loaded', array($this, 'backend_actions'), 100); |
|
| 56 | 56 | |
| 57 | 57 | //Hooks for no-conflict functionality |
| 58 | - add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000); |
|
| 59 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9); |
|
| 58 | + add_action('wp_print_scripts', array($this, 'no_conflict_scripts'), 1000); |
|
| 59 | + add_action('admin_print_footer_scripts', array($this, 'no_conflict_scripts'), 9); |
|
| 60 | 60 | |
| 61 | - add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000); |
|
| 62 | - add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11); |
|
| 63 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1); |
|
| 64 | - add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1); |
|
| 61 | + add_action('wp_print_styles', array($this, 'no_conflict_styles'), 1000); |
|
| 62 | + add_action('admin_print_styles', array($this, 'no_conflict_styles'), 11); |
|
| 63 | + add_action('admin_print_footer_scripts', array($this, 'no_conflict_styles'), 1); |
|
| 64 | + add_action('admin_footer', array($this, 'no_conflict_styles'), 1); |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | public function backend_actions() { |
| 75 | 75 | |
| 76 | 76 | /** @define "GRAVITYVIEW_DIR" "../" */ |
| 77 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.field.type.php' ); |
|
| 78 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.render.settings.php' ); |
|
| 79 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-label.php' ); |
|
| 80 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-views.php' ); |
|
| 81 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-welcome.php' ); |
|
| 82 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-add-shortcode.php' ); |
|
| 83 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 77 | + include_once(GRAVITYVIEW_DIR.'includes/admin/class.field.type.php'); |
|
| 78 | + include_once(GRAVITYVIEW_DIR.'includes/admin/class.render.settings.php'); |
|
| 79 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-label.php'); |
|
| 80 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-views.php'); |
|
| 81 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-welcome.php'); |
|
| 82 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-add-shortcode.php'); |
|
| 83 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-approve-entries.php'); |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * @action `gravityview_include_backend_actions` Triggered after all GravityView admin files are loaded |
@@ -99,19 +99,19 @@ discard block |
||
| 99 | 99 | * @param array $links Array of action links under GravityView on the plugin page |
| 100 | 100 | * @return array Action links with Settings and Support included, if the user has the appropriate caps |
| 101 | 101 | */ |
| 102 | - public static function plugin_action_links( $links ) { |
|
| 102 | + public static function plugin_action_links($links) { |
|
| 103 | 103 | |
| 104 | 104 | $actions = array(); |
| 105 | 105 | |
| 106 | - if( GVCommon::has_cap( 'gravityview_view_settings' ) ) { |
|
| 107 | - $actions[] = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ), esc_html__( 'Settings', 'gravityview' ) ); |
|
| 106 | + if (GVCommon::has_cap('gravityview_view_settings')) { |
|
| 107 | + $actions[] = sprintf('<a href="%s">%s</a>', admin_url('edit.php?post_type=gravityview&page=gravityview_settings'), esc_html__('Settings', 'gravityview')); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if( GVCommon::has_cap( 'gravityview_support_port' ) ) { |
|
| 111 | - $actions[] = '<a href="http://docs.gravityview.co">' . esc_html__( 'Support', 'gravityview' ) . '</a>'; |
|
| 110 | + if (GVCommon::has_cap('gravityview_support_port')) { |
|
| 111 | + $actions[] = '<a href="http://docs.gravityview.co">'.esc_html__('Support', 'gravityview').'</a>'; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - return array_merge( $actions, $links ); |
|
| 114 | + return array_merge($actions, $links); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -128,70 +128,70 @@ discard block |
||
| 128 | 128 | * @param array $messages Existing messages |
| 129 | 129 | * @return array Messages with GravityView views! |
| 130 | 130 | */ |
| 131 | - function post_updated_messages( $messages, $bulk_counts = NULL ) { |
|
| 131 | + function post_updated_messages($messages, $bulk_counts = NULL) { |
|
| 132 | 132 | global $post; |
| 133 | 133 | |
| 134 | - $post_id = isset($_GET['post']) ? intval($_GET['post']) : ( is_object( $post ) && isset( $post->ID ) ? $post->ID : NULL ); |
|
| 134 | + $post_id = isset($_GET['post']) ? intval($_GET['post']) : (is_object($post) && isset($post->ID) ? $post->ID : NULL); |
|
| 135 | 135 | |
| 136 | 136 | // By default, there will only be one item being modified. |
| 137 | 137 | // When in the `bulk_post_updated_messages` filter, there will be passed a number |
| 138 | 138 | // of modified items that will override this array. |
| 139 | - $bulk_counts = is_null( $bulk_counts ) ? array( 'updated' => 1 , 'locked' => 1 , 'deleted' => 1 , 'trashed' => 1, 'untrashed' => 1 ) : $bulk_counts; |
|
| 139 | + $bulk_counts = is_null($bulk_counts) ? array('updated' => 1, 'locked' => 1, 'deleted' => 1, 'trashed' => 1, 'untrashed' => 1) : $bulk_counts; |
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | // If we're starting fresh, a new form was created. |
| 143 | 143 | // We should let the user know this is the case. |
| 144 | - $start_fresh = get_post_meta( $post_id, '_gravityview_start_fresh', true ); |
|
| 144 | + $start_fresh = get_post_meta($post_id, '_gravityview_start_fresh', true); |
|
| 145 | 145 | |
| 146 | 146 | $new_form_text = ''; |
| 147 | 147 | |
| 148 | - if( !empty( $start_fresh ) ) { |
|
| 148 | + if (!empty($start_fresh)) { |
|
| 149 | 149 | |
| 150 | 150 | // Get the form that was created |
| 151 | - $connected_form = gravityview_get_form_id( $post_id ); |
|
| 151 | + $connected_form = gravityview_get_form_id($post_id); |
|
| 152 | 152 | |
| 153 | - if( !empty( $connected_form ) ) { |
|
| 154 | - $form = gravityview_get_form( $connected_form ); |
|
| 155 | - $form_name = esc_attr( $form['title'] ); |
|
| 153 | + if (!empty($connected_form)) { |
|
| 154 | + $form = gravityview_get_form($connected_form); |
|
| 155 | + $form_name = esc_attr($form['title']); |
|
| 156 | 156 | $image = self::get_floaty(); |
| 157 | - $new_form_text .= '<h3>'.$image.sprintf( __( 'A new form was created for this View: "%s"', 'gravityview' ), $form_name ).'</h3>'; |
|
| 158 | - $new_form_text .= sprintf( __( '%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
| 157 | + $new_form_text .= '<h3>'.$image.sprintf(__('A new form was created for this View: "%s"', 'gravityview'), $form_name).'</h3>'; |
|
| 158 | + $new_form_text .= sprintf(__('%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
| 159 | 159 | |
| 160 | 160 | You can %sedit the form%s in Gravity Forms and the updated fields will be available here. Don’t forget to %scustomize the form settings%s. |
| 161 | - ', 'gravityview' ), '<strong>', '</strong>', '<a href="'.site_url( '?gf_page=preview&id='.$connected_form ).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&id='.$connected_form ).'">', '</a>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&view=settings&id='.$connected_form ).'">', '</a>'); |
|
| 162 | - $new_form_text = wpautop( $new_form_text ); |
|
| 161 | + ', 'gravityview'), '<strong>', '</strong>', '<a href="'.site_url('?gf_page=preview&id='.$connected_form).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url('admin.php?page=gf_edit_forms&id='.$connected_form).'">', '</a>', '<a href="'.admin_url('admin.php?page=gf_edit_forms&view=settings&id='.$connected_form).'">', '</a>'); |
|
| 162 | + $new_form_text = wpautop($new_form_text); |
|
| 163 | 163 | |
| 164 | - delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
| 164 | + delete_post_meta($post_id, '_gravityview_start_fresh'); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $messages['gravityview'] = array( |
| 169 | 169 | 0 => '', // Unused. Messages start at index 1. |
| 170 | - 1 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
| 171 | - 2 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
| 172 | - 3 => __( 'View deleted.', 'gravityview' ), |
|
| 173 | - 4 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
| 170 | + 1 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
| 171 | + 2 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
| 172 | + 3 => __('View deleted.', 'gravityview'), |
|
| 173 | + 4 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
| 174 | 174 | /* translators: %s: date and time of the revision */ |
| 175 | - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'View restored to revision from %s', 'gravityview' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 176 | - 6 => sprintf(__( 'View published. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
| 177 | - 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
| 178 | - 8 => __( 'View submitted.', 'gravityview' ), |
|
| 175 | + 5 => isset($_GET['revision']) ? sprintf(__('View restored to revision from %s', 'gravityview'), wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
| 176 | + 6 => sprintf(__('View published. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>').$new_form_text, |
|
| 177 | + 7 => sprintf(__('View saved. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>').$new_form_text, |
|
| 178 | + 8 => __('View submitted.', 'gravityview'), |
|
| 179 | 179 | 9 => sprintf( |
| 180 | - __( 'View scheduled for: %1$s.', 'gravityview' ), |
|
| 180 | + __('View scheduled for: %1$s.', 'gravityview'), |
|
| 181 | 181 | // translators: Publish box date format, see http://php.net/date |
| 182 | - date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
|
| 183 | - ) . $new_form_text, |
|
| 184 | - 10 => sprintf(__( 'View draft updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
| 182 | + date_i18n(__('M j, Y @ G:i', 'gravityview'), strtotime((isset($post->post_date) ? $post->post_date : NULL))) |
|
| 183 | + ).$new_form_text, |
|
| 184 | + 10 => sprintf(__('View draft updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
| 185 | 185 | |
| 186 | 186 | /** |
| 187 | 187 | * These apply to `bulk_post_updated_messages` |
| 188 | 188 | * @file wp-admin/edit.php |
| 189 | 189 | */ |
| 190 | - 'updated' => _n( '%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview' ), |
|
| 191 | - 'locked' => _n( '%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview' ), |
|
| 192 | - 'deleted' => _n( '%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview' ), |
|
| 193 | - 'trashed' => _n( '%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview' ), |
|
| 194 | - 'untrashed' => _n( '%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview' ), |
|
| 190 | + 'updated' => _n('%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview'), |
|
| 191 | + 'locked' => _n('%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview'), |
|
| 192 | + 'deleted' => _n('%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview'), |
|
| 193 | + 'trashed' => _n('%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview'), |
|
| 194 | + 'untrashed' => _n('%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview'), |
|
| 195 | 195 | ); |
| 196 | 196 | |
| 197 | 197 | return $messages; |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | function no_conflict_scripts() { |
| 205 | 205 | global $wp_scripts; |
| 206 | 206 | |
| 207 | - if( ! gravityview_is_admin_page() ) { |
|
| 207 | + if (!gravityview_is_admin_page()) { |
|
| 208 | 208 | return; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | $no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode'); |
| 212 | 212 | |
| 213 | - if( empty( $no_conflict_mode ) ) { |
|
| 213 | + if (empty($no_conflict_mode)) { |
|
| 214 | 214 | return; |
| 215 | 215 | } |
| 216 | 216 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | 'jquery-ui-accordion', |
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | - $this->remove_conflicts( $wp_scripts, $wp_allowed_scripts, 'scripts' ); |
|
| 253 | + $this->remove_conflicts($wp_scripts, $wp_allowed_scripts, 'scripts'); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -260,16 +260,16 @@ discard block |
||
| 260 | 260 | function no_conflict_styles() { |
| 261 | 261 | global $wp_styles; |
| 262 | 262 | |
| 263 | - if( ! gravityview_is_admin_page() ) { |
|
| 263 | + if (!gravityview_is_admin_page()) { |
|
| 264 | 264 | return; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | // Dequeue other jQuery styles even if no-conflict is off. |
| 268 | 268 | // Terrible-looking tabs help no one. |
| 269 | - if( !empty( $wp_styles->registered ) ) { |
|
| 269 | + if (!empty($wp_styles->registered)) { |
|
| 270 | 270 | foreach ($wp_styles->registered as $key => $style) { |
| 271 | - if( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
| 272 | - wp_dequeue_style( $key ); |
|
| 271 | + if (preg_match('/^(?:wp\-)?jquery/ism', $key)) { |
|
| 272 | + wp_dequeue_style($key); |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | $no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode'); |
| 278 | 278 | |
| 279 | 279 | // If no conflict is off, jQuery will suffice. |
| 280 | - if( empty( $no_conflict_mode ) ) { |
|
| 280 | + if (empty($no_conflict_mode)) { |
|
| 281 | 281 | return; |
| 282 | 282 | } |
| 283 | 283 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | 'jquery-qtip.js', |
| 300 | 300 | ); |
| 301 | 301 | |
| 302 | - $this->remove_conflicts( $wp_styles, $wp_allowed_styles, 'styles' ); |
|
| 302 | + $this->remove_conflicts($wp_styles, $wp_allowed_styles, 'styles'); |
|
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | 305 | * @action `gravityview_remove_conflicts_after` Runs after no-conflict styles are removed. You can re-add styles here. |
@@ -315,31 +315,31 @@ discard block |
||
| 315 | 315 | * @param string $type Either 'styles' or 'scripts' |
| 316 | 316 | * @return void |
| 317 | 317 | */ |
| 318 | - private function remove_conflicts( &$wp_objects, $required_objects, $type = 'scripts' ) { |
|
| 318 | + private function remove_conflicts(&$wp_objects, $required_objects, $type = 'scripts') { |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
| 322 | 322 | * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
| 323 | 323 | * @param array $required_objects |
| 324 | 324 | */ |
| 325 | - $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
| 325 | + $required_objects = apply_filters("gravityview_noconflict_{$type}", $required_objects); |
|
| 326 | 326 | |
| 327 | 327 | //reset queue |
| 328 | 328 | $queue = array(); |
| 329 | - foreach( $wp_objects->queue as $object ) { |
|
| 330 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
| 329 | + foreach ($wp_objects->queue as $object) { |
|
| 330 | + if (in_array($object, $required_objects) || preg_match('/gravityview|gf_|gravityforms/ism', $object)) { |
|
| 331 | 331 | $queue[] = $object; |
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | 334 | $wp_objects->queue = $queue; |
| 335 | 335 | |
| 336 | - $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
| 336 | + $required_objects = $this->add_script_dependencies($wp_objects->registered, $required_objects); |
|
| 337 | 337 | |
| 338 | 338 | //unregistering scripts |
| 339 | 339 | $registered = array(); |
| 340 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
| 341 | - if( in_array( $handle, $required_objects ) ){ |
|
| 342 | - $registered[ $handle ] = $script_registration; |
|
| 340 | + foreach ($wp_objects->registered as $handle => $script_registration) { |
|
| 341 | + if (in_array($handle, $required_objects)) { |
|
| 342 | + $registered[$handle] = $script_registration; |
|
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | $wp_objects->registered = $registered; |
@@ -356,16 +356,16 @@ discard block |
||
| 356 | 356 | //gets all dependent scripts linked to the $scripts array passed |
| 357 | 357 | do { |
| 358 | 358 | $dependents = array(); |
| 359 | - foreach ( $scripts as $script ) { |
|
| 360 | - $deps = isset( $registered[ $script ] ) && is_array( $registered[ $script ]->deps ) ? $registered[ $script ]->deps : array(); |
|
| 361 | - foreach ( $deps as $dep ) { |
|
| 362 | - if ( ! in_array( $dep, $scripts ) && ! in_array( $dep, $dependents ) ) { |
|
| 359 | + foreach ($scripts as $script) { |
|
| 360 | + $deps = isset($registered[$script]) && is_array($registered[$script]->deps) ? $registered[$script]->deps : array(); |
|
| 361 | + foreach ($deps as $dep) { |
|
| 362 | + if (!in_array($dep, $scripts) && !in_array($dep, $dependents)) { |
|
| 363 | 363 | $dependents[] = $dep; |
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | - $scripts = array_merge( $scripts, $dependents ); |
|
| 368 | - } while ( ! empty( $dependents ) ); |
|
| 367 | + $scripts = array_merge($scripts, $dependents); |
|
| 368 | + } while (!empty($dependents)); |
|
| 369 | 369 | |
| 370 | 370 | return $scripts; |
| 371 | 371 | } |
@@ -385,8 +385,8 @@ discard block |
||
| 385 | 385 | * @deprecated since 1.12 |
| 386 | 386 | * @param array $notice Array with `class` and `message` keys. The message is not escaped. |
| 387 | 387 | */ |
| 388 | - public static function add_notice( $notice = array() ) { |
|
| 389 | - GravityView_Admin_Notices::add_notice( $notice ); |
|
| 388 | + public static function add_notice($notice = array()) { |
|
| 389 | + GravityView_Admin_Notices::add_notice($notice); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | /** |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
| 410 | 410 | */ |
| 411 | - static function get_plugin_status( $location = '' ) { |
|
| 412 | - return GravityView_Compatibility::get_plugin_status( $location ); |
|
| 411 | + static function get_plugin_status($location = '') { |
|
| 412 | + return GravityView_Compatibility::get_plugin_status($location); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
@@ -421,10 +421,10 @@ discard block |
||
| 421 | 421 | * |
| 422 | 422 | * @return bool|string|void If `false`, not a GravityView page. `true` if $page is passed and is the same as current page. Otherwise, the name of the page (`single`, `settings`, or `views`) |
| 423 | 423 | */ |
| 424 | - static function is_admin_page( $hook = '', $page = NULL ) { |
|
| 424 | + static function is_admin_page($hook = '', $page = NULL) { |
|
| 425 | 425 | global $current_screen, $plugin_page, $pagenow, $post; |
| 426 | 426 | |
| 427 | - if( ! is_admin() ) { return false; } |
|
| 427 | + if (!is_admin()) { return false; } |
|
| 428 | 428 | |
| 429 | 429 | $is_page = false; |
| 430 | 430 | |
@@ -432,21 +432,21 @@ discard block |
||
| 432 | 432 | |
| 433 | 433 | $is_gv_post_type_get = (isset($_GET['post_type']) && $_GET['post_type'] === 'gravityview'); |
| 434 | 434 | |
| 435 | - $is_gv_settings_get = isset( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings'; |
|
| 435 | + $is_gv_settings_get = isset($_GET['page']) && $_GET['page'] === 'gravityview_settings'; |
|
| 436 | 436 | |
| 437 | - if( empty( $post ) && $pagenow === 'post.php' && !empty( $_GET['post'] ) ) { |
|
| 438 | - $gv_post = get_post( intval( $_GET['post'] ) ); |
|
| 437 | + if (empty($post) && $pagenow === 'post.php' && !empty($_GET['post'])) { |
|
| 438 | + $gv_post = get_post(intval($_GET['post'])); |
|
| 439 | 439 | $is_gv_post_type = (!empty($gv_post) && !empty($gv_post->post_type) && $gv_post->post_type === 'gravityview'); |
| 440 | 440 | } else { |
| 441 | 441 | $is_gv_post_type = (!empty($post) && !empty($post->post_type) && $post->post_type === 'gravityview'); |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if( $is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get ) { |
|
| 444 | + if ($is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get) { |
|
| 445 | 445 | |
| 446 | 446 | // $_GET `post_type` variable |
| 447 | - if(in_array($pagenow, array( 'post.php' , 'post-new.php' )) ) { |
|
| 447 | + if (in_array($pagenow, array('post.php', 'post-new.php'))) { |
|
| 448 | 448 | $is_page = 'single'; |
| 449 | - } else if ( in_array( $plugin_page, array( 'gravityview_settings', 'gravityview_page_gravityview_settings' ) ) || ( !empty( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings' ) ) { |
|
| 449 | + } else if (in_array($plugin_page, array('gravityview_settings', 'gravityview_page_gravityview_settings')) || (!empty($_GET['page']) && $_GET['page'] === 'gravityview_settings')) { |
|
| 450 | 450 | $is_page = 'settings'; |
| 451 | 451 | } else { |
| 452 | 452 | $is_page = 'views'; |
@@ -458,10 +458,10 @@ discard block |
||
| 458 | 458 | * @param[in,out] string|bool $is_page If false, no. If string, the name of the page (`single`, `settings`, or `views`) |
| 459 | 459 | * @param[in] string $hook The name of the page to check against. Is passed to the method. |
| 460 | 460 | */ |
| 461 | - $is_page = apply_filters( 'gravityview_is_admin_page', $is_page, $hook ); |
|
| 461 | + $is_page = apply_filters('gravityview_is_admin_page', $is_page, $hook); |
|
| 462 | 462 | |
| 463 | 463 | // If the current page is the same as the compared page |
| 464 | - if( !empty( $page ) ) { |
|
| 464 | + if (!empty($page)) { |
|
| 465 | 465 | return $is_page === $page; |
| 466 | 466 | } |
| 467 | 467 | |
@@ -473,5 +473,5 @@ discard block |
||
| 473 | 473 | new GravityView_Admin; |
| 474 | 474 | |
| 475 | 475 | function gravityview_is_admin_page($hook = '', $page = NULL) { |
| 476 | - return GravityView_Admin::is_admin_page( $hook, $page ); |
|
| 476 | + return GravityView_Admin::is_admin_page($hook, $page); |
|
| 477 | 477 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @since 1.15 |
| 29 | 29 | * @param bool|false $mixed |
| 30 | 30 | * |
| 31 | - * @return bool |
|
| 31 | + * @return boolean|null |
|
| 32 | 32 | */ |
| 33 | 33 | private function _exit( $mixed = NULL ) { |
| 34 | 34 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * Import Gravity Form XML or JSON |
| 201 | 201 | * |
| 202 | 202 | * @param string $xml_or_json_path Path to form XML or JSON file |
| 203 | - * @return int|bool Imported form ID or false |
|
| 203 | + * @return false|string Imported form ID or false |
|
| 204 | 204 | */ |
| 205 | 205 | function import_form( $xml_or_json_path = '' ) { |
| 206 | 206 | |
@@ -5,21 +5,21 @@ discard block |
||
| 5 | 5 | function __construct() { |
| 6 | 6 | |
| 7 | 7 | //get field options |
| 8 | - add_action( 'wp_ajax_gv_field_options', array( $this, 'get_field_options' ) ); |
|
| 8 | + add_action('wp_ajax_gv_field_options', array($this, 'get_field_options')); |
|
| 9 | 9 | |
| 10 | 10 | // get available fields |
| 11 | - add_action( 'wp_ajax_gv_available_fields', array( $this, 'get_available_fields_html' ) ); |
|
| 11 | + add_action('wp_ajax_gv_available_fields', array($this, 'get_available_fields_html')); |
|
| 12 | 12 | |
| 13 | 13 | // get active areas |
| 14 | - add_action( 'wp_ajax_gv_get_active_areas', array( $this, 'get_active_areas' ) ); |
|
| 14 | + add_action('wp_ajax_gv_get_active_areas', array($this, 'get_active_areas')); |
|
| 15 | 15 | |
| 16 | 16 | // get preset fields |
| 17 | - add_action( 'wp_ajax_gv_get_preset_fields', array( $this, 'get_preset_fields_config' ) ); |
|
| 17 | + add_action('wp_ajax_gv_get_preset_fields', array($this, 'get_preset_fields_config')); |
|
| 18 | 18 | |
| 19 | 19 | // get preset fields |
| 20 | - add_action( 'wp_ajax_gv_set_preset_form', array( $this, 'create_preset_form' ) ); |
|
| 20 | + add_action('wp_ajax_gv_set_preset_form', array($this, 'create_preset_form')); |
|
| 21 | 21 | |
| 22 | - add_action( 'wp_ajax_gv_sortable_fields_form', array( $this, 'get_sortable_fields' ) ); |
|
| 22 | + add_action('wp_ajax_gv_sortable_fields_form', array($this, 'get_sortable_fields')); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | - private function _exit( $mixed = NULL ) { |
|
| 33 | + private function _exit($mixed = NULL) { |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Don't exit if we're running test suite. |
| 37 | 37 | * @since 1.15 |
| 38 | 38 | */ |
| 39 | - if( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) { |
|
| 39 | + if (defined('DOING_GRAVITYVIEW_TESTS') && DOING_GRAVITYVIEW_TESTS) { |
|
| 40 | 40 | return $mixed; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - exit( $mixed ); |
|
| 43 | + exit($mixed); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** -------- AJAX ---------- */ |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | 52 | function check_ajax_nonce() { |
| 53 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxviews' ) ) { |
|
| 54 | - $this->_exit( false ); |
|
| 53 | + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxviews')) { |
|
| 54 | + $this->_exit(false); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -67,20 +67,20 @@ discard block |
||
| 67 | 67 | //check nonce |
| 68 | 68 | $this->check_ajax_nonce(); |
| 69 | 69 | |
| 70 | - $context = isset($_POST['context']) ? esc_attr( $_POST['context'] ) : 'directory'; |
|
| 70 | + $context = isset($_POST['context']) ? esc_attr($_POST['context']) : 'directory'; |
|
| 71 | 71 | |
| 72 | 72 | // If Form was changed, JS sends form ID, if start fresh, JS sends template_id |
| 73 | - if( !empty( $_POST['form_id'] ) ) { |
|
| 74 | - do_action( 'gravityview_render_available_fields', (int) $_POST['form_id'], $context ); |
|
| 73 | + if (!empty($_POST['form_id'])) { |
|
| 74 | + do_action('gravityview_render_available_fields', (int)$_POST['form_id'], $context); |
|
| 75 | 75 | $this->_exit(); |
| 76 | - } elseif( !empty( $_POST['template_id'] ) ) { |
|
| 77 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 78 | - do_action( 'gravityview_render_available_fields', $form, $context ); |
|
| 76 | + } elseif (!empty($_POST['template_id'])) { |
|
| 77 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
| 78 | + do_action('gravityview_render_available_fields', $form, $context); |
|
| 79 | 79 | $this->_exit(); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | //if everything fails.. |
| 83 | - $this->_exit( false ); |
|
| 83 | + $this->_exit(false); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
@@ -94,21 +94,21 @@ discard block |
||
| 94 | 94 | function get_active_areas() { |
| 95 | 95 | $this->check_ajax_nonce(); |
| 96 | 96 | |
| 97 | - if( empty( $_POST['template_id'] ) ) { |
|
| 98 | - $this->_exit( false ); |
|
| 97 | + if (empty($_POST['template_id'])) { |
|
| 98 | + $this->_exit(false); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | ob_start(); |
| 102 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true ); |
|
| 102 | + do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true); |
|
| 103 | 103 | $response['directory'] = ob_get_clean(); |
| 104 | 104 | |
| 105 | 105 | ob_start(); |
| 106 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true ); |
|
| 106 | + do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true); |
|
| 107 | 107 | $response['single'] = ob_get_clean(); |
| 108 | 108 | |
| 109 | - $response = array_map( 'gravityview_strip_whitespace', $response ); |
|
| 109 | + $response = array_map('gravityview_strip_whitespace', $response); |
|
| 110 | 110 | |
| 111 | - $this->_exit( json_encode( $response ) ); |
|
| 111 | + $this->_exit(json_encode($response)); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -119,49 +119,49 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $this->check_ajax_nonce(); |
| 121 | 121 | |
| 122 | - if( empty( $_POST['template_id'] ) ) { |
|
| 123 | - $this->_exit( false ); |
|
| 122 | + if (empty($_POST['template_id'])) { |
|
| 123 | + $this->_exit(false); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // get the fields xml config file for this specific preset |
| 127 | - $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] ); |
|
| 127 | + $preset_fields_path = apply_filters('gravityview_template_fieldsxml', array(), $_POST['template_id']); |
|
| 128 | 128 | // import fields |
| 129 | - if( !empty( $preset_fields_path ) ) { |
|
| 130 | - $presets = $this->import_fields( $preset_fields_path ); |
|
| 129 | + if (!empty($preset_fields_path)) { |
|
| 130 | + $presets = $this->import_fields($preset_fields_path); |
|
| 131 | 131 | } else { |
| 132 | - $presets = array( 'widgets' => array(), 'fields' => array() ); |
|
| 132 | + $presets = array('widgets' => array(), 'fields' => array()); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $template_id = esc_attr( $_POST['template_id'] ); |
|
| 135 | + $template_id = esc_attr($_POST['template_id']); |
|
| 136 | 136 | |
| 137 | 137 | // template areas |
| 138 | - $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
|
| 139 | - $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
| 138 | + $template_areas_directory = apply_filters('gravityview_template_active_areas', array(), $template_id, 'directory'); |
|
| 139 | + $template_areas_single = apply_filters('gravityview_template_active_areas', array(), $template_id, 'single'); |
|
| 140 | 140 | |
| 141 | 141 | // widget areas |
| 142 | 142 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
| 143 | 143 | |
| 144 | 144 | ob_start(); |
| 145 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] ); |
|
| 145 | + do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets']); |
|
| 146 | 146 | $response['header'] = ob_get_clean(); |
| 147 | 147 | |
| 148 | 148 | ob_start(); |
| 149 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] ); |
|
| 149 | + do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets']); |
|
| 150 | 150 | $response['footer'] = ob_get_clean(); |
| 151 | 151 | |
| 152 | 152 | ob_start(); |
| 153 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] ); |
|
| 153 | + do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields']); |
|
| 154 | 154 | $response['directory'] = ob_get_clean(); |
| 155 | 155 | |
| 156 | 156 | ob_start(); |
| 157 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] ); |
|
| 157 | + do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields']); |
|
| 158 | 158 | $response['single'] = ob_get_clean(); |
| 159 | 159 | |
| 160 | - $response = array_map( 'gravityview_strip_whitespace', $response ); |
|
| 160 | + $response = array_map('gravityview_strip_whitespace', $response); |
|
| 161 | 161 | |
| 162 | - do_action( 'gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response ); |
|
| 162 | + do_action('gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response); |
|
| 163 | 163 | |
| 164 | - $this->_exit( json_encode( $response ) ); |
|
| 164 | + $this->_exit(json_encode($response)); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -173,26 +173,26 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | $this->check_ajax_nonce(); |
| 175 | 175 | |
| 176 | - if( empty( $_POST['template_id'] ) ) { |
|
| 177 | - do_action( 'gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.' ); |
|
| 178 | - $this->_exit( false ); |
|
| 176 | + if (empty($_POST['template_id'])) { |
|
| 177 | + do_action('gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.'); |
|
| 178 | + $this->_exit(false); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // get the xml for this specific template_id |
| 182 | - $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] ); |
|
| 182 | + $preset_form_xml_path = apply_filters('gravityview_template_formxml', '', $_POST['template_id']); |
|
| 183 | 183 | |
| 184 | 184 | // import form |
| 185 | - $form = $this->import_form( $preset_form_xml_path ); |
|
| 185 | + $form = $this->import_form($preset_form_xml_path); |
|
| 186 | 186 | |
| 187 | 187 | // get the form ID |
| 188 | - if( false === $form ) { |
|
| 188 | + if (false === $form) { |
|
| 189 | 189 | // send error to user |
| 190 | - do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int) $_POST['template_id'] ); |
|
| 190 | + do_action('gravityview_log_error', '[create_preset_form] Error importing form for template id: '.(int)$_POST['template_id']); |
|
| 191 | 191 | |
| 192 | - $this->_exit( false ); |
|
| 192 | + $this->_exit(false); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - $this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' ); |
|
| 195 | + $this->_exit('<option value="'.esc_attr($form['id']).'" selected="selected">'.esc_html($form['title']).'</option>'); |
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
@@ -202,24 +202,24 @@ discard block |
||
| 202 | 202 | * @param string $xml_or_json_path Path to form XML or JSON file |
| 203 | 203 | * @return int|bool Imported form ID or false |
| 204 | 204 | */ |
| 205 | - function import_form( $xml_or_json_path = '' ) { |
|
| 205 | + function import_form($xml_or_json_path = '') { |
|
| 206 | 206 | |
| 207 | - do_action( 'gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path ); |
|
| 207 | + do_action('gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path); |
|
| 208 | 208 | |
| 209 | - if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) { |
|
| 210 | - do_action( 'gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path ); |
|
| 209 | + if (empty($xml_or_json_path) || !class_exists('GFExport') || !file_exists($xml_or_json_path)) { |
|
| 210 | + do_action('gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path); |
|
| 211 | 211 | return false; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // import form |
| 215 | 215 | $forms = ''; |
| 216 | - $count = GFExport::import_file( $xml_or_json_path, $forms ); |
|
| 216 | + $count = GFExport::import_file($xml_or_json_path, $forms); |
|
| 217 | 217 | |
| 218 | - do_action( 'gravityview_log_debug', '[import_form] Importing form (Result)', $count ); |
|
| 219 | - do_action( 'gravityview_log_debug', '[import_form] Importing form (Form) ', $forms ); |
|
| 218 | + do_action('gravityview_log_debug', '[import_form] Importing form (Result)', $count); |
|
| 219 | + do_action('gravityview_log_debug', '[import_form] Importing form (Form) ', $forms); |
|
| 220 | 220 | |
| 221 | - if( $count != 1 || empty( $forms[0]['id'] ) ) { |
|
| 222 | - do_action( 'gravityview_log_error', '[import_form] Form Import Failed!' ); |
|
| 221 | + if ($count != 1 || empty($forms[0]['id'])) { |
|
| 222 | + do_action('gravityview_log_error', '[import_form] Form Import Failed!'); |
|
| 223 | 223 | return false; |
| 224 | 224 | } |
| 225 | 225 | |
@@ -238,26 +238,26 @@ discard block |
||
| 238 | 238 | function get_field_options() { |
| 239 | 239 | $this->check_ajax_nonce(); |
| 240 | 240 | |
| 241 | - if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) { |
|
| 242 | - do_action( 'gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. ' ); |
|
| 243 | - $this->_exit( false ); |
|
| 241 | + if (empty($_POST['template']) || empty($_POST['area']) || empty($_POST['field_id']) || empty($_POST['field_type'])) { |
|
| 242 | + do_action('gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. '); |
|
| 243 | + $this->_exit(false); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | // Fix apostrophes added by JSON response |
| 247 | - $_post = array_map( 'stripslashes_deep', $_POST ); |
|
| 247 | + $_post = array_map('stripslashes_deep', $_POST); |
|
| 248 | 248 | |
| 249 | 249 | // Sanitize |
| 250 | - $_post = array_map( 'esc_attr', $_post ); |
|
| 250 | + $_post = array_map('esc_attr', $_post); |
|
| 251 | 251 | |
| 252 | 252 | // The GF type of field: `product`, `name`, `creditcard`, `id`, `text` |
| 253 | - $input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL; |
|
| 254 | - $context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL; |
|
| 253 | + $input_type = isset($_post['input_type']) ? esc_attr($_post['input_type']) : NULL; |
|
| 254 | + $context = isset($_post['context']) ? esc_attr($_post['context']) : NULL; |
|
| 255 | 255 | |
| 256 | - $response = GravityView_Render_Settings::render_field_options( $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context ); |
|
| 256 | + $response = GravityView_Render_Settings::render_field_options($_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context); |
|
| 257 | 257 | |
| 258 | - $response = gravityview_strip_whitespace( $response ); |
|
| 258 | + $response = gravityview_strip_whitespace($response); |
|
| 259 | 259 | |
| 260 | - $this->_exit( $response ); |
|
| 260 | + $this->_exit($response); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -274,23 +274,23 @@ discard block |
||
| 274 | 274 | $form = ''; |
| 275 | 275 | |
| 276 | 276 | // if form id is set, use it, else, get form from preset |
| 277 | - if( !empty( $_POST['form_id'] ) ) { |
|
| 277 | + if (!empty($_POST['form_id'])) { |
|
| 278 | 278 | |
| 279 | - $form = (int) $_POST['form_id']; |
|
| 279 | + $form = (int)$_POST['form_id']; |
|
| 280 | 280 | |
| 281 | 281 | } |
| 282 | 282 | // get form from preset |
| 283 | - elseif( !empty( $_POST['template_id'] ) ) { |
|
| 283 | + elseif (!empty($_POST['template_id'])) { |
|
| 284 | 284 | |
| 285 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 285 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
| 286 | 286 | |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - $response = gravityview_get_sortable_fields( $form ); |
|
| 289 | + $response = gravityview_get_sortable_fields($form); |
|
| 290 | 290 | |
| 291 | - $response = gravityview_strip_whitespace( $response ); |
|
| 291 | + $response = gravityview_strip_whitespace($response); |
|
| 292 | 292 | |
| 293 | - $this->_exit( $response ); |
|
| 293 | + $this->_exit($response); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -298,35 +298,35 @@ discard block |
||
| 298 | 298 | * @param string $template_id Preset template |
| 299 | 299 | * |
| 300 | 300 | */ |
| 301 | - static function pre_get_form_fields( $template_id = '') { |
|
| 301 | + static function pre_get_form_fields($template_id = '') { |
|
| 302 | 302 | |
| 303 | - if( empty( $template_id ) ) { |
|
| 304 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Template ID not set.' ); |
|
| 303 | + if (empty($template_id)) { |
|
| 304 | + do_action('gravityview_log_error', __METHOD__.' - Template ID not set.'); |
|
| 305 | 305 | return false; |
| 306 | 306 | } else { |
| 307 | - $form_file = apply_filters( 'gravityview_template_formxml', '', $template_id ); |
|
| 308 | - if( !file_exists( $form_file ) ) { |
|
| 309 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset ['. $template_id .']. File not found. file: ' . $form_file ); |
|
| 307 | + $form_file = apply_filters('gravityview_template_formxml', '', $template_id); |
|
| 308 | + if (!file_exists($form_file)) { |
|
| 309 | + do_action('gravityview_log_error', __METHOD__.' - Importing Form Fields for preset ['.$template_id.']. File not found. file: '.$form_file); |
|
| 310 | 310 | return false; |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // Load xml parser (from GravityForms) |
| 315 | - if( class_exists( 'GFCommon' ) ) { |
|
| 316 | - $xml_parser = GFCommon::get_base_path() . '/xml.php'; |
|
| 315 | + if (class_exists('GFCommon')) { |
|
| 316 | + $xml_parser = GFCommon::get_base_path().'/xml.php'; |
|
| 317 | 317 | } else { |
| 318 | - $xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php'; |
|
| 318 | + $xml_parser = trailingslashit(WP_PLUGIN_DIR).'gravityforms/xml.php'; |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if( file_exists( $xml_parser ) ) { |
|
| 322 | - require_once( $xml_parser ); |
|
| 321 | + if (file_exists($xml_parser)) { |
|
| 322 | + require_once($xml_parser); |
|
| 323 | 323 | } else { |
| 324 | - do_action( 'gravityview_log_debug', __METHOD__ . ' - Gravity Forms XML Parser not found.', $xml_parser ); |
|
| 324 | + do_action('gravityview_log_debug', __METHOD__.' - Gravity Forms XML Parser not found.', $xml_parser); |
|
| 325 | 325 | return false; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | // load file |
| 329 | - $xmlstr = file_get_contents( $form_file ); |
|
| 329 | + $xmlstr = file_get_contents($form_file); |
|
| 330 | 330 | |
| 331 | 331 | $options = array( |
| 332 | 332 | "page" => array("unserialize_as_array" => true), |
@@ -345,21 +345,21 @@ discard block |
||
| 345 | 345 | $xml = new RGXML($options); |
| 346 | 346 | $forms = $xml->unserialize($xmlstr); |
| 347 | 347 | |
| 348 | - if( !$forms ) { |
|
| 349 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); |
|
| 348 | + if (!$forms) { |
|
| 349 | + do_action('gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. Error importing file. (File)', $form_file); |
|
| 350 | 350 | return false; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
| 353 | + if (!empty($forms[0]) && is_array($forms[0])) { |
|
| 354 | 354 | $form = $forms[0]; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if( empty( $form ) ) { |
|
| 358 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
|
| 357 | + if (empty($form)) { |
|
| 358 | + do_action('gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms); |
|
| 359 | 359 | return false; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); |
|
| 362 | + do_action('gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. (Form)', $form); |
|
| 363 | 363 | |
| 364 | 364 | return $form; |
| 365 | 365 | |
@@ -371,46 +371,46 @@ discard block |
||
| 371 | 371 | * @param string $file path to file |
| 372 | 372 | * @return array Fields config array (unserialized) |
| 373 | 373 | */ |
| 374 | - function import_fields( $file ) { |
|
| 374 | + function import_fields($file) { |
|
| 375 | 375 | |
| 376 | - if( empty( $file ) || !file_exists( $file ) ) { |
|
| 377 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file ); |
|
| 376 | + if (empty($file) || !file_exists($file)) { |
|
| 377 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file); |
|
| 378 | 378 | return false; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - if( !class_exists('WXR_Parser') ) { |
|
| 382 | - include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php'; |
|
| 381 | + if (!class_exists('WXR_Parser')) { |
|
| 382 | + include_once GRAVITYVIEW_DIR.'includes/lib/xml-parsers/parsers.php'; |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | $parser = new WXR_Parser(); |
| 386 | - $presets = $parser->parse( $file ); |
|
| 386 | + $presets = $parser->parse($file); |
|
| 387 | 387 | |
| 388 | - if(is_wp_error( $presets )) { |
|
| 389 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets ); |
|
| 388 | + if (is_wp_error($presets)) { |
|
| 389 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets); |
|
| 390 | 390 | return false; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) { |
|
| 394 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file ); |
|
| 393 | + if (empty($presets['posts'][0]['postmeta']) && !is_array($presets['posts'][0]['postmeta'])) { |
|
| 394 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file); |
|
| 395 | 395 | return false; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta'] ); |
|
| 398 | + do_action('gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta']); |
|
| 399 | 399 | |
| 400 | 400 | $fields = $widgets = array(); |
| 401 | - foreach( $presets['posts'][0]['postmeta'] as $meta ) { |
|
| 401 | + foreach ($presets['posts'][0]['postmeta'] as $meta) { |
|
| 402 | 402 | switch ($meta['key']) { |
| 403 | 403 | case '_gravityview_directory_fields': |
| 404 | - $fields = maybe_unserialize( $meta['value'] ); |
|
| 404 | + $fields = maybe_unserialize($meta['value']); |
|
| 405 | 405 | break; |
| 406 | 406 | case '_gravityview_directory_widgets': |
| 407 | - $widgets = maybe_unserialize( $meta['value'] ); |
|
| 407 | + $widgets = maybe_unserialize($meta['value']); |
|
| 408 | 408 | break; |
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields ); |
|
| 413 | - do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets ); |
|
| 412 | + do_action('gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields); |
|
| 413 | + do_action('gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets); |
|
| 414 | 414 | |
| 415 | 415 | return array( |
| 416 | 416 | 'fields' => $fields, |
@@ -113,6 +113,9 @@ discard block |
||
| 113 | 113 | return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | + /** |
|
| 117 | + * @return GravityView_View_Data |
|
| 118 | + */ |
|
| 116 | 119 | public static function getInstance( $passed_post = NULL ) { |
| 117 | 120 | |
| 118 | 121 | if( empty( self::$instance ) ) { |
@@ -152,7 +155,7 @@ discard block |
||
| 152 | 155 | * within the WordPress database. |
| 153 | 156 | * |
| 154 | 157 | * @see http://tommcfarlin.com/wordpress-post-exists-by-id/ Fastest check available |
| 155 | - * @param int $id The ID of the post to check |
|
| 158 | + * @param integer $view_id |
|
| 156 | 159 | * @return bool True if the post exists; otherwise, false. |
| 157 | 160 | * @since 1.0.0 |
| 158 | 161 | */ |
@@ -299,7 +302,7 @@ discard block |
||
| 299 | 302 | * |
| 300 | 303 | * @access public |
| 301 | 304 | * @param array $properties |
| 302 | - * @return void|boolean (field should be hidden) or false (field should be presented) |
|
| 305 | + * @return boolean (field should be hidden) or false (field should be presented) |
|
| 303 | 306 | */ |
| 304 | 307 | private function hide_field_check_conditions( $properties ) { |
| 305 | 308 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** If this file is called directly, abort. */ |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if (!defined('ABSPATH')) { |
|
| 5 | 5 | die; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @param null $passed_post |
| 17 | 17 | */ |
| 18 | - private function __construct( $passed_post = NULL ) { |
|
| 18 | + private function __construct($passed_post = NULL) { |
|
| 19 | 19 | |
| 20 | - if( !empty( $passed_post ) ) { |
|
| 20 | + if (!empty($passed_post)) { |
|
| 21 | 21 | |
| 22 | - $id_or_id_array = $this->maybe_get_view_id( $passed_post ); |
|
| 22 | + $id_or_id_array = $this->maybe_get_view_id($passed_post); |
|
| 23 | 23 | |
| 24 | - if( !empty( $id_or_id_array ) ) { |
|
| 25 | - $this->add_view( $id_or_id_array ); |
|
| 24 | + if (!empty($id_or_id_array)) { |
|
| 25 | + $this->add_view($id_or_id_array); |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | public function has_multiple_views() { |
| 35 | 35 | |
| 36 | 36 | //multiple views |
| 37 | - return count( $this->get_views() ) > 1 ? true : false; |
|
| 37 | + return count($this->get_views()) > 1 ? true : false; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
@@ -52,37 +52,37 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return int|null|array ID of the View. If there are multiple views in the content, array of IDs parsed. |
| 54 | 54 | */ |
| 55 | - public function maybe_get_view_id( $passed_post ) { |
|
| 55 | + public function maybe_get_view_id($passed_post) { |
|
| 56 | 56 | |
| 57 | 57 | $ids = array(); |
| 58 | 58 | |
| 59 | - if( ! empty( $passed_post ) ) { |
|
| 59 | + if (!empty($passed_post)) { |
|
| 60 | 60 | |
| 61 | - if( is_numeric( $passed_post ) ) { |
|
| 62 | - $passed_post = get_post( $passed_post ); |
|
| 61 | + if (is_numeric($passed_post)) { |
|
| 62 | + $passed_post = get_post($passed_post); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Convert WP_Posts into WP_Posts[] array |
| 66 | - if( $passed_post instanceof WP_Post ) { |
|
| 67 | - $passed_post = array( $passed_post ); |
|
| 66 | + if ($passed_post instanceof WP_Post) { |
|
| 67 | + $passed_post = array($passed_post); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if( is_array( $passed_post ) ) { |
|
| 70 | + if (is_array($passed_post)) { |
|
| 71 | 71 | |
| 72 | - foreach ( $passed_post as &$post) { |
|
| 73 | - if( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
| 72 | + foreach ($passed_post as &$post) { |
|
| 73 | + if ((get_post_type($post) === 'gravityview')) { |
|
| 74 | 74 | $ids[] = $post->ID; |
| 75 | - } else{ |
|
| 75 | + } else { |
|
| 76 | 76 | // Parse the Post Content |
| 77 | - $id = $this->parse_post_content( $post->post_content ); |
|
| 78 | - if( $id ) { |
|
| 79 | - $ids = array_merge( $ids, (array) $id ); |
|
| 77 | + $id = $this->parse_post_content($post->post_content); |
|
| 78 | + if ($id) { |
|
| 79 | + $ids = array_merge($ids, (array)$id); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // Parse the Post Meta |
| 83 | - $id = $this->parse_post_meta( $post->ID ); |
|
| 84 | - if( $id ) { |
|
| 85 | - $ids = array_merge( $ids, (array) $id ); |
|
| 83 | + $id = $this->parse_post_meta($post->ID); |
|
| 84 | + if ($id) { |
|
| 85 | + $ids = array_merge($ids, (array)$id); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -90,33 +90,33 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | } else { |
| 92 | 92 | |
| 93 | - if ( is_string( $passed_post ) ) { |
|
| 93 | + if (is_string($passed_post)) { |
|
| 94 | 94 | |
| 95 | - $id = $this->parse_post_content( $passed_post ); |
|
| 96 | - if( $id ) { |
|
| 97 | - $ids = array_merge( $ids, (array) $id ); |
|
| 95 | + $id = $this->parse_post_content($passed_post); |
|
| 96 | + if ($id) { |
|
| 97 | + $ids = array_merge($ids, (array)$id); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | } else { |
| 101 | - $id = $this->get_id_from_atts( $passed_post ); |
|
| 102 | - $ids[] = intval( $id ); |
|
| 101 | + $id = $this->get_id_from_atts($passed_post); |
|
| 102 | + $ids[] = intval($id); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if( empty($ids) ) { |
|
| 107 | + if (empty($ids)) { |
|
| 108 | 108 | return NULL; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // If it's just one ID, return that. |
| 112 | 112 | // Otherwise, return array of IDs |
| 113 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
| 113 | + return (sizeof($ids) === 1) ? $ids[0] : $ids; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - public static function getInstance( $passed_post = NULL ) { |
|
| 116 | + public static function getInstance($passed_post = NULL) { |
|
| 117 | 117 | |
| 118 | - if( empty( self::$instance ) ) { |
|
| 119 | - self::$instance = new GravityView_View_Data( $passed_post ); |
|
| 118 | + if (empty(self::$instance)) { |
|
| 119 | + self::$instance = new GravityView_View_Data($passed_post); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | return self::$instance; |
@@ -126,25 +126,25 @@ discard block |
||
| 126 | 126 | return $this->views; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - function get_view( $view_id, $atts = NULL ) { |
|
| 129 | + function get_view($view_id, $atts = NULL) { |
|
| 130 | 130 | |
| 131 | - if( ! is_numeric( $view_id) ) { |
|
| 132 | - do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) ); |
|
| 131 | + if (!is_numeric($view_id)) { |
|
| 132 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id)); |
|
| 133 | 133 | return false; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Backup: the view hasn't been fetched yet. Doing it now. |
| 137 | - if ( ! isset( $this->views[ $view_id ] ) ) { |
|
| 138 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) ); |
|
| 139 | - return $this->add_view( $view_id, $atts ); |
|
| 137 | + if (!isset($this->views[$view_id])) { |
|
| 138 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id)); |
|
| 139 | + return $this->add_view($view_id, $atts); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if ( empty( $this->views[ $view_id ] ) ) { |
|
| 143 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) ); |
|
| 142 | + if (empty($this->views[$view_id])) { |
|
| 143 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id)); |
|
| 144 | 144 | return false; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - return $this->views[ $view_id ]; |
|
| 147 | + return $this->views[$view_id]; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | * @return bool True if the post exists; otherwise, false. |
| 157 | 157 | * @since 1.0.0 |
| 158 | 158 | */ |
| 159 | - function view_exists( $view_id ) { |
|
| 160 | - return is_string( get_post_status( $view_id ) ); |
|
| 159 | + function view_exists($view_id) { |
|
| 160 | + return is_string(get_post_status($view_id)); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -168,56 +168,56 @@ discard block |
||
| 168 | 168 | * @param array|string $atts Combine other attributes (eg. from shortcode) with the view settings (optional) |
| 169 | 169 | * @return type |
| 170 | 170 | */ |
| 171 | - function add_view( $view_id, $atts = NULL ) { |
|
| 171 | + function add_view($view_id, $atts = NULL) { |
|
| 172 | 172 | |
| 173 | 173 | // Handle array of IDs |
| 174 | - if( is_array( $view_id ) ) { |
|
| 175 | - foreach( $view_id as $id ) { |
|
| 174 | + if (is_array($view_id)) { |
|
| 175 | + foreach ($view_id as $id) { |
|
| 176 | 176 | |
| 177 | - $this->add_view( $id, $atts ); |
|
| 177 | + $this->add_view($id, $atts); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | return $this->views; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // The view has been set already; returning stored view. |
| 184 | - if ( !empty( $this->views[ $view_id ] ) ) { |
|
| 185 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) ); |
|
| 186 | - return $this->views[ $view_id ]; |
|
| 184 | + if (!empty($this->views[$view_id])) { |
|
| 185 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id)); |
|
| 186 | + return $this->views[$view_id]; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if( ! $this->view_exists( $view_id ) ) { |
|
| 190 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) ); |
|
| 189 | + if (!$this->view_exists($view_id)) { |
|
| 190 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id)); |
|
| 191 | 191 | return false; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - $form_id = gravityview_get_form_id( $view_id ); |
|
| 194 | + $form_id = gravityview_get_form_id($view_id); |
|
| 195 | 195 | |
| 196 | - if( empty( $form_id ) ) { |
|
| 196 | + if (empty($form_id)) { |
|
| 197 | 197 | |
| 198 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) ); |
|
| 198 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id)); |
|
| 199 | 199 | |
| 200 | 200 | return false; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // Get the settings for the View ID |
| 204 | - $view_settings = gravityview_get_template_settings( $view_id ); |
|
| 204 | + $view_settings = gravityview_get_template_settings($view_id); |
|
| 205 | 205 | |
| 206 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings ); |
|
| 206 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings); |
|
| 207 | 207 | |
| 208 | 208 | // Merge the view settings with the defaults |
| 209 | - $view_defaults = wp_parse_args( $view_settings, self::get_default_args() ); |
|
| 209 | + $view_defaults = wp_parse_args($view_settings, self::get_default_args()); |
|
| 210 | 210 | |
| 211 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
| 211 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults); |
|
| 212 | 212 | |
| 213 | - if( ! empty( $atts ) && is_array( $atts ) ) { |
|
| 213 | + if (!empty($atts) && is_array($atts)) { |
|
| 214 | 214 | |
| 215 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
| 215 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts); |
|
| 216 | 216 | |
| 217 | 217 | // Get the settings from the shortcode and merge them with defaults. |
| 218 | - $atts = shortcode_atts( $view_defaults, $atts ); |
|
| 218 | + $atts = shortcode_atts($view_defaults, $atts); |
|
| 219 | 219 | |
| 220 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
| 220 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts); |
|
| 221 | 221 | |
| 222 | 222 | } else { |
| 223 | 223 | |
@@ -226,24 +226,24 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - unset( $atts['id'], $view_defaults, $view_settings ); |
|
| 229 | + unset($atts['id'], $view_defaults, $view_settings); |
|
| 230 | 230 | |
| 231 | 231 | $data = array( |
| 232 | 232 | 'id' => $view_id, |
| 233 | 233 | 'view_id' => $view_id, |
| 234 | 234 | 'form_id' => $form_id, |
| 235 | - 'template_id' => gravityview_get_template_id( $view_id ), |
|
| 235 | + 'template_id' => gravityview_get_template_id($view_id), |
|
| 236 | 236 | 'atts' => $atts, |
| 237 | - 'fields' => $this->get_fields( $view_id ), |
|
| 238 | - 'widgets' => get_post_meta( $view_id, '_gravityview_directory_widgets', true ), |
|
| 239 | - 'form' => gravityview_get_form( $form_id ), |
|
| 237 | + 'fields' => $this->get_fields($view_id), |
|
| 238 | + 'widgets' => get_post_meta($view_id, '_gravityview_directory_widgets', true), |
|
| 239 | + 'form' => gravityview_get_form($form_id), |
|
| 240 | 240 | ); |
| 241 | 241 | |
| 242 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data ); |
|
| 242 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data); |
|
| 243 | 243 | |
| 244 | - $this->views[ $view_id ] = $data; |
|
| 244 | + $this->views[$view_id] = $data; |
|
| 245 | 245 | |
| 246 | - return $this->views[ $view_id ]; |
|
| 246 | + return $this->views[$view_id]; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -253,14 +253,14 @@ discard block |
||
| 253 | 253 | * @param int $view_id View ID |
| 254 | 254 | * @return array Array of fields as passed by `gravityview_get_directory_fields()` |
| 255 | 255 | */ |
| 256 | - function get_fields( $view_id ) { |
|
| 256 | + function get_fields($view_id) { |
|
| 257 | 257 | |
| 258 | - $dir_fields = gravityview_get_directory_fields( $view_id ); |
|
| 259 | - do_action( 'gravityview_log_debug', '[render_view] Fields: ', $dir_fields ); |
|
| 258 | + $dir_fields = gravityview_get_directory_fields($view_id); |
|
| 259 | + do_action('gravityview_log_debug', '[render_view] Fields: ', $dir_fields); |
|
| 260 | 260 | |
| 261 | 261 | // remove fields according to visitor visibility permissions (if logged-in) |
| 262 | - $dir_fields = $this->filter_fields( $dir_fields ); |
|
| 263 | - do_action( 'gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields ); |
|
| 262 | + $dir_fields = $this->filter_fields($dir_fields); |
|
| 263 | + do_action('gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields); |
|
| 264 | 264 | |
| 265 | 265 | return $dir_fields; |
| 266 | 266 | } |
@@ -272,18 +272,18 @@ discard block |
||
| 272 | 272 | * @param array $dir_fields |
| 273 | 273 | * @return array |
| 274 | 274 | */ |
| 275 | - private function filter_fields( $dir_fields ) { |
|
| 275 | + private function filter_fields($dir_fields) { |
|
| 276 | 276 | |
| 277 | - if( empty( $dir_fields ) || !is_array( $dir_fields ) ) { |
|
| 277 | + if (empty($dir_fields) || !is_array($dir_fields)) { |
|
| 278 | 278 | return $dir_fields; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - foreach( $dir_fields as $area => $fields ) { |
|
| 281 | + foreach ($dir_fields as $area => $fields) { |
|
| 282 | 282 | |
| 283 | - foreach( (array)$fields as $uniqid => $properties ) { |
|
| 283 | + foreach ((array)$fields as $uniqid => $properties) { |
|
| 284 | 284 | |
| 285 | - if( $this->hide_field_check_conditions( $properties ) ) { |
|
| 286 | - unset( $dir_fields[ $area ][ $uniqid ] ); |
|
| 285 | + if ($this->hide_field_check_conditions($properties)) { |
|
| 286 | + unset($dir_fields[$area][$uniqid]); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | } |
@@ -301,31 +301,31 @@ discard block |
||
| 301 | 301 | * @param array $properties |
| 302 | 302 | * @return void|boolean (field should be hidden) or false (field should be presented) |
| 303 | 303 | */ |
| 304 | - private function hide_field_check_conditions( $properties ) { |
|
| 304 | + private function hide_field_check_conditions($properties) { |
|
| 305 | 305 | |
| 306 | 306 | // logged-in visibility |
| 307 | - if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) { |
|
| 307 | + if (!empty($properties['only_loggedin']) && !GVCommon::has_cap($properties['only_loggedin_cap'])) { |
|
| 308 | 308 | return true; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | return false; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - function get_id_from_atts( $atts ) { |
|
| 314 | + function get_id_from_atts($atts) { |
|
| 315 | 315 | |
| 316 | - $atts = is_array( $atts ) ? $atts : shortcode_parse_atts( $atts ); |
|
| 316 | + $atts = is_array($atts) ? $atts : shortcode_parse_atts($atts); |
|
| 317 | 317 | |
| 318 | 318 | // Get the settings from the shortcode and merge them with defaults. |
| 319 | - $atts = wp_parse_args( $atts, self::get_default_args() ); |
|
| 319 | + $atts = wp_parse_args($atts, self::get_default_args()); |
|
| 320 | 320 | |
| 321 | - $view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL; |
|
| 321 | + $view_id = !empty($atts['view_id']) ? (int)$atts['view_id'] : NULL; |
|
| 322 | 322 | |
| 323 | - if( empty( $view_id ) && !empty( $atts['id'] ) ) { |
|
| 323 | + if (empty($view_id) && !empty($atts['id'])) { |
|
| 324 | 324 | $view_id = (int)$atts['id']; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if( empty( $view_id ) ) { |
|
| 328 | - do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
| 327 | + if (empty($view_id)) { |
|
| 328 | + do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts); |
|
| 329 | 329 | return; |
| 330 | 330 | } |
| 331 | 331 | |
@@ -341,50 +341,50 @@ discard block |
||
| 341 | 341 | * @param string $content $post->post_content content |
| 342 | 342 | * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, NULL |
| 343 | 343 | */ |
| 344 | - function parse_post_content( $content ) { |
|
| 344 | + function parse_post_content($content) { |
|
| 345 | 345 | |
| 346 | 346 | /** |
| 347 | 347 | * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin |
| 348 | 348 | * @since 1.6 |
| 349 | 349 | */ |
| 350 | - if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) { |
|
| 350 | + if (!shortcode_exists('gravityview') && class_exists('GravityView_Shortcode')) { |
|
| 351 | 351 | new GravityView_Shortcode; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' ); |
|
| 354 | + $shortcodes = gravityview_has_shortcode_r($content, 'gravityview'); |
|
| 355 | 355 | |
| 356 | - if( empty( $shortcodes ) ) { |
|
| 356 | + if (empty($shortcodes)) { |
|
| 357 | 357 | return NULL; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
| 360 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes); |
|
| 361 | 361 | |
| 362 | 362 | $ids = array(); |
| 363 | 363 | |
| 364 | 364 | foreach ($shortcodes as $key => $shortcode) { |
| 365 | 365 | |
| 366 | - $args = shortcode_parse_atts( $shortcode[3] ); |
|
| 366 | + $args = shortcode_parse_atts($shortcode[3]); |
|
| 367 | 367 | |
| 368 | - if( empty( $args['id'] ) ) { |
|
| 369 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode ); |
|
| 368 | + if (empty($args['id'])) { |
|
| 369 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID), $shortcode); |
|
| 370 | 370 | continue; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args ); |
|
| 373 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args); |
|
| 374 | 374 | |
| 375 | 375 | // Store the View to the object for later fetching. |
| 376 | - $this->add_view( $args['id'], $args ); |
|
| 376 | + $this->add_view($args['id'], $args); |
|
| 377 | 377 | |
| 378 | 378 | $ids[] = $args['id']; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - if( empty($ids) ) { |
|
| 381 | + if (empty($ids)) { |
|
| 382 | 382 | return NULL; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | // If it's just one ID, return that. |
| 386 | 386 | // Otherwise, return array of IDs |
| 387 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
| 387 | + return (sizeof($ids) === 1) ? $ids[0] : $ids; |
|
| 388 | 388 | |
| 389 | 389 | } |
| 390 | 390 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | * @param int $post_id WP_Post ID |
| 396 | 396 | * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, or meta not parsed, NULL |
| 397 | 397 | */ |
| 398 | - private function parse_post_meta( $post_id ) { |
|
| 398 | + private function parse_post_meta($post_id) { |
|
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | 401 | * @filter `gravityview/data/parse/meta_keys` Define meta keys to parse to check for GravityView shortcode content |
@@ -403,32 +403,32 @@ discard block |
||
| 403 | 403 | * @param[in,out] array $meta_keys Array of key values to check. If empty, do not check. Default: empty array |
| 404 | 404 | * @param[in] int $post_id ID of the post being checked |
| 405 | 405 | */ |
| 406 | - $meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id ); |
|
| 406 | + $meta_keys = (array)apply_filters('gravityview/data/parse/meta_keys', array(), $post_id); |
|
| 407 | 407 | |
| 408 | - if( empty( $meta_keys ) ) { |
|
| 408 | + if (empty($meta_keys)) { |
|
| 409 | 409 | return NULL; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys ); |
|
| 412 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys); |
|
| 413 | 413 | |
| 414 | 414 | $meta_content = ''; |
| 415 | 415 | |
| 416 | - foreach( $meta_keys as $key ) { |
|
| 417 | - $meta = get_post_meta( $post_id, $key , true ); |
|
| 418 | - if( ! is_string( $meta ) ) { |
|
| 416 | + foreach ($meta_keys as $key) { |
|
| 417 | + $meta = get_post_meta($post_id, $key, true); |
|
| 418 | + if (!is_string($meta)) { |
|
| 419 | 419 | continue; |
| 420 | 420 | } |
| 421 | - $meta_content .= $meta . ' '; |
|
| 421 | + $meta_content .= $meta.' '; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - if( empty( $meta_content ) ) { |
|
| 425 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); |
|
| 424 | + if (empty($meta_content)) { |
|
| 425 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id), $meta_keys); |
|
| 426 | 426 | return NULL; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content ); |
|
| 429 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content); |
|
| 430 | 430 | |
| 431 | - return $this->parse_post_content( $meta_content ); |
|
| 431 | + return $this->parse_post_content($meta_content); |
|
| 432 | 432 | |
| 433 | 433 | } |
| 434 | 434 | |
@@ -444,61 +444,61 @@ discard block |
||
| 444 | 444 | * |
| 445 | 445 | * @return bool|WP_Error If valid, returns true. If invalid, returns WP_Error containing error message. |
| 446 | 446 | */ |
| 447 | - public static function is_valid_embed_id( $post_id = '', $view_id = '', $empty_is_valid = true ) { |
|
| 447 | + public static function is_valid_embed_id($post_id = '', $view_id = '', $empty_is_valid = true) { |
|
| 448 | 448 | |
| 449 | 449 | $message = NULL; |
| 450 | 450 | |
| 451 | 451 | // Not invalid if not set! |
| 452 | - if( empty( $post_id ) || empty( $view_id ) ) { |
|
| 452 | + if (empty($post_id) || empty($view_id)) { |
|
| 453 | 453 | |
| 454 | - if( $empty_is_valid ) { |
|
| 454 | + if ($empty_is_valid) { |
|
| 455 | 455 | return true; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - $message = esc_html__( 'The ID is required.', 'gravityview' ); |
|
| 458 | + $message = esc_html__('The ID is required.', 'gravityview'); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - if( ! $message ) { |
|
| 462 | - $status = get_post_status( $post_id ); |
|
| 461 | + if (!$message) { |
|
| 462 | + $status = get_post_status($post_id); |
|
| 463 | 463 | |
| 464 | 464 | // Nothing exists with that post ID. |
| 465 | - if ( ! is_numeric( $post_id ) ) { |
|
| 466 | - $message = esc_html__( 'You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview' ); |
|
| 465 | + if (!is_numeric($post_id)) { |
|
| 466 | + $message = esc_html__('You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview'); |
|
| 467 | 467 | |
| 468 | 468 | // @todo Convert to generic article about Embed IDs |
| 469 | - $message .= ' ' . gravityview_get_link( 'http://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
| 469 | + $message .= ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview'), 'target=_blank'); |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - if( ! $message ) { |
|
| 473 | + if (!$message) { |
|
| 474 | 474 | |
| 475 | 475 | // Nothing exists with that post ID. |
| 476 | - if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) { |
|
| 477 | - $message = esc_html__( 'There is no post or page with that ID.', 'gravityview' ); |
|
| 476 | + if (empty($status) || in_array($status, array('revision', 'attachment'))) { |
|
| 477 | + $message = esc_html__('There is no post or page with that ID.', 'gravityview'); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - if( ! $message ) { |
|
| 483 | - $view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id ); |
|
| 482 | + if (!$message) { |
|
| 483 | + $view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id($post_id); |
|
| 484 | 484 | |
| 485 | 485 | // The post or page specified does not contain the shortcode. |
| 486 | - if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) { |
|
| 487 | - $message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' ); |
|
| 486 | + if (false === in_array($view_id, (array)$view_ids_in_post)) { |
|
| 487 | + $message = sprintf(esc_html__('The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview'), '<br /><code>[gravityview id="'.intval($view_id).'"]</code>'); |
|
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | - if( ! $message ) { |
|
| 491 | + if (!$message) { |
|
| 492 | 492 | |
| 493 | 493 | // It's a View |
| 494 | - if( 'gravityview' === get_post_type( $post_id ) ) { |
|
| 495 | - $message = esc_html__( 'The ID is already a View.', 'gravityview' );; |
|
| 494 | + if ('gravityview' === get_post_type($post_id)) { |
|
| 495 | + $message = esc_html__('The ID is already a View.', 'gravityview'); ; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - if( $message ) { |
|
| 501 | - return new WP_Error( 'invalid_embed_id', $message ); |
|
| 500 | + if ($message) { |
|
| 501 | + return new WP_Error('invalid_embed_id', $message); |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | return true; |
@@ -510,13 +510,13 @@ discard block |
||
| 510 | 510 | * @param boolean $with_details Include details |
| 511 | 511 | * @return mixed|array If using $with_details, return array. Otherwise, mixed. |
| 512 | 512 | */ |
| 513 | - public static function get_default_arg( $key, $with_details = false ) { |
|
| 513 | + public static function get_default_arg($key, $with_details = false) { |
|
| 514 | 514 | |
| 515 | - $args = self::get_default_args( $with_details ); |
|
| 515 | + $args = self::get_default_args($with_details); |
|
| 516 | 516 | |
| 517 | - if( !isset( $args[ $key ] ) ) { return NULL; } |
|
| 517 | + if (!isset($args[$key])) { return NULL; } |
|
| 518 | 518 | |
| 519 | - return $args[ $key ]; |
|
| 519 | + return $args[$key]; |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
@@ -535,13 +535,13 @@ discard block |
||
| 535 | 535 | * @param[out] array $options Array of values to use when generating select, multiselect, radio, or checkboxes fields |
| 536 | 536 | * @param[out] boolean $full_width True: Display the input and label together when rendering. False: Display label and input in separate columns when rendering. |
| 537 | 537 | */ |
| 538 | - public static function get_default_args( $with_details = false, $group = NULL ) { |
|
| 538 | + public static function get_default_args($with_details = false, $group = NULL) { |
|
| 539 | 539 | |
| 540 | 540 | /** |
| 541 | 541 | * @filter `gravityview_default_args` Modify the default settings for new Views |
| 542 | 542 | * @param[in,out] array $default_args Array of default args. |
| 543 | 543 | */ |
| 544 | - $default_settings = apply_filters( 'gravityview_default_args', array( |
|
| 544 | + $default_settings = apply_filters('gravityview_default_args', array( |
|
| 545 | 545 | 'id' => array( |
| 546 | 546 | 'label' => __('View ID', 'gravityview'), |
| 547 | 547 | 'type' => 'number', |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | 'show_in_shortcode' => true, |
| 560 | 560 | ), |
| 561 | 561 | 'lightbox' => array( |
| 562 | - 'label' => __( 'Enable lightbox for images', 'gravityview' ), |
|
| 562 | + 'label' => __('Enable lightbox for images', 'gravityview'), |
|
| 563 | 563 | 'type' => 'checkbox', |
| 564 | 564 | 'group' => 'default', |
| 565 | 565 | 'value' => 1, |
@@ -567,29 +567,29 @@ discard block |
||
| 567 | 567 | 'show_in_shortcode' => true, |
| 568 | 568 | ), |
| 569 | 569 | 'show_only_approved' => array( |
| 570 | - 'label' => __( 'Show only approved entries', 'gravityview' ), |
|
| 570 | + 'label' => __('Show only approved entries', 'gravityview'), |
|
| 571 | 571 | 'type' => 'checkbox', |
| 572 | 572 | 'group' => 'default', |
| 573 | 573 | 'value' => 0, |
| 574 | 574 | 'show_in_shortcode' => false, |
| 575 | 575 | ), |
| 576 | 576 | 'hide_until_searched' => array( |
| 577 | - 'label' => __( 'Hide View data until search is performed', 'gravityview' ), |
|
| 577 | + 'label' => __('Hide View data until search is performed', 'gravityview'), |
|
| 578 | 578 | 'type' => 'checkbox', |
| 579 | 579 | 'group' => 'default', |
| 580 | - 'tooltip' => __( 'When enabled it will only show any View entries after a search is performed.', 'gravityview' ), |
|
| 580 | + 'tooltip' => __('When enabled it will only show any View entries after a search is performed.', 'gravityview'), |
|
| 581 | 581 | 'value' => 0, |
| 582 | 582 | 'show_in_shortcode' => false, |
| 583 | 583 | ), |
| 584 | 584 | 'hide_empty' => array( |
| 585 | - 'label' => __( 'Hide empty fields', 'gravityview' ), |
|
| 585 | + 'label' => __('Hide empty fields', 'gravityview'), |
|
| 586 | 586 | 'group' => 'default', |
| 587 | 587 | 'type' => 'checkbox', |
| 588 | 588 | 'value' => 1, |
| 589 | 589 | 'show_in_shortcode' => false, |
| 590 | 590 | ), |
| 591 | 591 | 'user_edit' => array( |
| 592 | - 'label' => __( 'Allow User Edit', 'gravityview' ), |
|
| 592 | + 'label' => __('Allow User Edit', 'gravityview'), |
|
| 593 | 593 | 'group' => 'default', |
| 594 | 594 | 'desc' => __('Allow logged-in users to edit entries they created.', 'gravityview'), |
| 595 | 595 | 'value' => 0, |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | 'show_in_shortcode' => true, |
| 599 | 599 | ), |
| 600 | 600 | 'user_delete' => array( |
| 601 | - 'label' => __( 'Allow User Delete', 'gravityview' ), |
|
| 601 | + 'label' => __('Allow User Delete', 'gravityview'), |
|
| 602 | 602 | 'group' => 'default', |
| 603 | 603 | 'desc' => __('Allow logged-in users to delete entries they created.', 'gravityview'), |
| 604 | 604 | 'value' => 0, |
@@ -612,8 +612,8 @@ discard block |
||
| 612 | 612 | 'value' => '', |
| 613 | 613 | 'group' => 'sort', |
| 614 | 614 | 'options' => array( |
| 615 | - '' => __( 'Default', 'gravityview'), |
|
| 616 | - 'date_created' => __( 'Date Created', 'gravityview'), |
|
| 615 | + '' => __('Default', 'gravityview'), |
|
| 616 | + 'date_created' => __('Date Created', 'gravityview'), |
|
| 617 | 617 | ), |
| 618 | 618 | 'show_in_shortcode' => true, |
| 619 | 619 | ), |
@@ -630,19 +630,19 @@ discard block |
||
| 630 | 630 | 'show_in_shortcode' => true, |
| 631 | 631 | ), |
| 632 | 632 | 'sort_columns' => array( |
| 633 | - 'label' => __( 'Enable sorting by column', 'gravityview' ), |
|
| 634 | - 'left_label' => __( 'Column Sorting', 'gravityview' ), |
|
| 633 | + 'label' => __('Enable sorting by column', 'gravityview'), |
|
| 634 | + 'left_label' => __('Column Sorting', 'gravityview'), |
|
| 635 | 635 | 'type' => 'checkbox', |
| 636 | 636 | 'value' => false, |
| 637 | 637 | 'group' => 'sort', |
| 638 | 638 | 'tooltip' => NULL, |
| 639 | 639 | 'show_in_shortcode' => true, |
| 640 | - 'show_in_template' => array( 'default_table' ), |
|
| 640 | + 'show_in_template' => array('default_table'), |
|
| 641 | 641 | ), |
| 642 | 642 | 'start_date' => array( |
| 643 | 643 | 'label' => __('Filter by Start Date', 'gravityview'), |
| 644 | 644 | 'class' => 'gv-datepicker', |
| 645 | - 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
| 645 | + 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview'), |
|
| 646 | 646 | 'type' => 'text', |
| 647 | 647 | 'value' => '', |
| 648 | 648 | 'group' => 'filter', |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | 'end_date' => array( |
| 652 | 652 | 'label' => __('Filter by End Date', 'gravityview'), |
| 653 | 653 | 'class' => 'gv-datepicker', |
| 654 | - 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
| 654 | + 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview'), |
|
| 655 | 655 | 'type' => 'text', |
| 656 | 656 | 'value' => '', |
| 657 | 657 | 'group' => 'filter', |
@@ -711,12 +711,12 @@ discard block |
||
| 711 | 711 | )); |
| 712 | 712 | |
| 713 | 713 | // By default, we only want the key => value pairing, not the whole array. |
| 714 | - if( empty( $with_details ) ) { |
|
| 714 | + if (empty($with_details)) { |
|
| 715 | 715 | |
| 716 | 716 | $defaults = array(); |
| 717 | 717 | |
| 718 | - foreach( $default_settings as $key => $value ) { |
|
| 719 | - $defaults[ $key ] = $value['value']; |
|
| 718 | + foreach ($default_settings as $key => $value) { |
|
| 719 | + $defaults[$key] = $value['value']; |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | return $defaults; |
@@ -729,9 +729,9 @@ discard block |
||
| 729 | 729 | |
| 730 | 730 | // If the $group argument is set for the method, |
| 731 | 731 | // ignore any settings that aren't in that group. |
| 732 | - if( !empty( $group ) && is_string( $group ) ) { |
|
| 733 | - if( empty( $value['group'] ) || $value['group'] !== $group ) { |
|
| 734 | - unset( $default_settings[ $key ] ); |
|
| 732 | + if (!empty($group) && is_string($group)) { |
|
| 733 | + if (empty($value['group']) || $value['group'] !== $group) { |
|
| 734 | + unset($default_settings[$key]); |
|
| 735 | 735 | } |
| 736 | 736 | } |
| 737 | 737 | |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Should the panel be shown? If there are notices or warnings, yes. |
| 51 | - * @return boolean true: show panel; false: hide panel |
|
| 51 | + * @return boolean|null true: show panel; false: hide panel |
|
| 52 | 52 | */ |
| 53 | 53 | function set_visible( $visible = '' ) { |
| 54 | 54 | $this->_visible = ( count( $this->get_notices() ) || count( $this->get_warnings() ) ); |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | function init() { |
| 22 | 22 | |
| 23 | 23 | $icon = is_admin() ? '<i class="icon gv-icon-astronaut-head"></i> ' : NULL; |
| 24 | - $this->title( $icon . __('GravityView', 'gravityview') ); |
|
| 24 | + $this->title($icon.__('GravityView', 'gravityview')); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | function get_warnings() { |
| 28 | 28 | |
| 29 | - if( is_null( $this->warnings ) ) { |
|
| 29 | + if (is_null($this->warnings)) { |
|
| 30 | 30 | $this->warnings = GravityView_Logging::get_errors(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | function get_notices() { |
| 37 | 37 | |
| 38 | - if( is_null( $this->notices ) ) { |
|
| 38 | + if (is_null($this->notices)) { |
|
| 39 | 39 | $this->notices = GravityView_Logging::get_notices(); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | * Should the panel be shown? If there are notices or warnings, yes. |
| 51 | 51 | * @return boolean true: show panel; false: hide panel |
| 52 | 52 | */ |
| 53 | - function set_visible( $visible = '' ) { |
|
| 54 | - $this->_visible = ( count( $this->get_notices() ) || count( $this->get_warnings() ) ); |
|
| 53 | + function set_visible($visible = '') { |
|
| 54 | + $this->_visible = (count($this->get_notices()) || count($this->get_warnings())); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -83,42 +83,42 @@ discard block |
||
| 83 | 83 | </style> |
| 84 | 84 | <div id='debug-bar-gravityview'>"; |
| 85 | 85 | |
| 86 | - $output .= '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ).'" class="alignright" alt="" width="100" height="132" />'; |
|
| 86 | + $output .= '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE).'" class="alignright" alt="" width="100" height="132" />'; |
|
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | $warnings = $this->get_warnings(); |
| 90 | 90 | $notices = $this->get_notices(); |
| 91 | 91 | |
| 92 | - if(count($warnings)) { |
|
| 92 | + if (count($warnings)) { |
|
| 93 | 93 | $output .= '<h3><span>'.__('Warnings', 'gravityview').'</span></h3>'; |
| 94 | 94 | $output .= '<ol>'; |
| 95 | - foreach ( $warnings as $key => $notice) { |
|
| 96 | - if(empty($notice['message'])) { continue; } |
|
| 97 | - $output .= '<li><a href="#'.sanitize_html_class( 'gv-warning-' . $key ).'">'.strip_tags($notice['message']).'</a></li>'; |
|
| 95 | + foreach ($warnings as $key => $notice) { |
|
| 96 | + if (empty($notice['message'])) { continue; } |
|
| 97 | + $output .= '<li><a href="#'.sanitize_html_class('gv-warning-'.$key).'">'.strip_tags($notice['message']).'</a></li>'; |
|
| 98 | 98 | } |
| 99 | 99 | $output .= '</ol><hr />'; |
| 100 | 100 | } |
| 101 | - if(count($notices)) { |
|
| 101 | + if (count($notices)) { |
|
| 102 | 102 | $output .= '<h3><span>'.__('Logs', 'gravityview').'</span></h3>'; |
| 103 | 103 | $output .= '<ol>'; |
| 104 | - foreach ( $notices as $key => $notice) { |
|
| 105 | - if(empty($notice['message'])) { continue; } |
|
| 106 | - $output .= '<li><a href="#'.sanitize_html_class( 'gv-notice-' . $key ).'">'.strip_tags($notice['message']).'</a></li>'; |
|
| 104 | + foreach ($notices as $key => $notice) { |
|
| 105 | + if (empty($notice['message'])) { continue; } |
|
| 106 | + $output .= '<li><a href="#'.sanitize_html_class('gv-notice-'.$key).'">'.strip_tags($notice['message']).'</a></li>'; |
|
| 107 | 107 | } |
| 108 | 108 | $output .= '</ol><hr />'; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if ( count( $warnings ) ) { |
|
| 111 | + if (count($warnings)) { |
|
| 112 | 112 | $output .= '<h3>Warnings</h3>'; |
| 113 | 113 | $output .= '<ol class="debug-bar-php-list">'; |
| 114 | - foreach ( $warnings as $key => $notice) { $output .= $this->render_item( $notice, 'gv-warning-' . $key ); } |
|
| 114 | + foreach ($warnings as $key => $notice) { $output .= $this->render_item($notice, 'gv-warning-'.$key); } |
|
| 115 | 115 | $output .= '</ol>'; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ( count( $notices ) ) { |
|
| 118 | + if (count($notices)) { |
|
| 119 | 119 | $output .= '<h3>Notices</h3>'; |
| 120 | 120 | $output .= '<ol class="debug-bar-php-list">'; |
| 121 | - foreach ( $notices as $key => $notice) { $output .= $this->render_item( $notice, 'gv-notice-' . $key ); } |
|
| 121 | + foreach ($notices as $key => $notice) { $output .= $this->render_item($notice, 'gv-notice-'.$key); } |
|
| 122 | 122 | $output .= '</ol>'; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | * @return string Escaped HTML |
| 134 | 134 | */ |
| 135 | 135 | function esc_html_recursive($item) { |
| 136 | - if(is_object($item)) { |
|
| 137 | - foreach($item as $key => $value) { |
|
| 136 | + if (is_object($item)) { |
|
| 137 | + foreach ($item as $key => $value) { |
|
| 138 | 138 | $item->{$key} = $this->esc_html_recursive($value); |
| 139 | 139 | } |
| 140 | - } else if(is_array($item)) { |
|
| 141 | - foreach($item as $key => $value) { |
|
| 140 | + } else if (is_array($item)) { |
|
| 141 | + foreach ($item as $key => $value) { |
|
| 142 | 142 | $item[$key] = $this->esc_html_recursive($value); |
| 143 | 143 | } |
| 144 | 144 | } else { |
@@ -154,31 +154,31 @@ discard block |
||
| 154 | 154 | * @param string $anchor The anchor ID for the item |
| 155 | 155 | * @return string HTML output |
| 156 | 156 | */ |
| 157 | - function render_item( $notice, $anchor = '' ) { |
|
| 157 | + function render_item($notice, $anchor = '') { |
|
| 158 | 158 | |
| 159 | 159 | $output = ''; |
| 160 | 160 | |
| 161 | - if(!empty($notice['message'])) { |
|
| 162 | - $output .= '<a id="'.sanitize_html_class( $anchor ).'"></a>'; |
|
| 161 | + if (!empty($notice['message'])) { |
|
| 162 | + $output .= '<a id="'.sanitize_html_class($anchor).'"></a>'; |
|
| 163 | 163 | $output .= "<li class='debug-bar-php-notice'>"; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | $output .= '<div class="clear"></div>'; |
| 167 | 167 | |
| 168 | 168 | // Title |
| 169 | - $output .= '<div class="gravityview-debug-bar-title">'.esc_attr( $notice['message'] ).'</div>'; |
|
| 169 | + $output .= '<div class="gravityview-debug-bar-title">'.esc_attr($notice['message']).'</div>'; |
|
| 170 | 170 | |
| 171 | 171 | // Debugging Output |
| 172 | - if( empty( $notice['data'] ) ) { |
|
| 173 | - if( !is_null( $notice['data'] ) ) { |
|
| 174 | - $output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview' ).'</em>'; |
|
| 172 | + if (empty($notice['data'])) { |
|
| 173 | + if (!is_null($notice['data'])) { |
|
| 174 | + $output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview').'</em>'; |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | else { |
| 178 | - $output .= sprintf( '<pre>%s</pre>', print_r($this->esc_html_recursive( $notice['data'] ), true) ); |
|
| 178 | + $output .= sprintf('<pre>%s</pre>', print_r($this->esc_html_recursive($notice['data']), true)); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if(!empty($notice['message'])) { |
|
| 181 | + if (!empty($notice['message'])) { |
|
| 182 | 182 | $output .= '</li>'; |
| 183 | 183 | } |
| 184 | 184 | |