@@ -42,16 +42,16 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $args = wp_parse_args( $args, $defaults ); |
| 44 | 44 | |
| 45 | - $forms = gravityview_get_forms( (bool) $args['active'], (bool) $args['trash'] ); |
|
| 45 | + $forms = gravityview_get_forms( (bool)$args[ 'active' ], (bool)$args[ 'trash' ] ); |
|
| 46 | 46 | |
| 47 | - if( array() === $args['options'] ) { |
|
| 47 | + if ( array() === $args[ 'options' ] ) { |
|
| 48 | 48 | foreach ( $forms as $form ) { |
| 49 | 49 | |
| 50 | - if ( in_array( $form['id'], $args['exclude'] ) ) { |
|
| 50 | + if ( in_array( $form[ 'id' ], $args[ 'exclude' ] ) ) { |
|
| 51 | 51 | continue; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $args['options'][ $form['id'] ] = esc_html( $form['title'] ); |
|
| 54 | + $args[ 'options' ][ $form[ 'id' ] ] = esc_html( $form[ 'title' ] ); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | $args = wp_parse_args( $args, $defaults ); |
| 85 | 85 | |
| 86 | - if( empty( $args['form_id'] ) ) { |
|
| 86 | + if ( empty( $args[ 'form_id' ] ) ) { |
|
| 87 | 87 | return ''; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $fields = GVCommon::get_sortable_fields_array( $args['form_id'] ); |
|
| 90 | + $fields = GVCommon::get_sortable_fields_array( $args[ 'form_id' ] ); |
|
| 91 | 91 | |
| 92 | - if( array() === $args['options'] ) { |
|
| 92 | + if ( array() === $args[ 'options' ] ) { |
|
| 93 | 93 | foreach ( $fields as $field_id => $field ) { |
| 94 | - $args['options'][ $field_id ] = esc_html( $field['label'] ); |
|
| 94 | + $args[ 'options' ][ $field_id ] = esc_html( $field[ 'label' ] ); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
@@ -127,43 +127,43 @@ discard block |
||
| 127 | 127 | $args = wp_parse_args( $args, $defaults ); |
| 128 | 128 | |
| 129 | 129 | $data_elements = ''; |
| 130 | - foreach ( $args['data'] as $key => $value ) { |
|
| 130 | + foreach ( $args[ 'data' ] as $key => $value ) { |
|
| 131 | 131 | $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if( $args['multiple'] ) { |
|
| 134 | + if ( $args[ 'multiple' ] ) { |
|
| 135 | 135 | $multiple = ' MULTIPLE'; |
| 136 | 136 | } else { |
| 137 | 137 | $multiple = ''; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if( $args['placeholder'] ) { |
|
| 141 | - $placeholder = $args['placeholder']; |
|
| 140 | + if ( $args[ 'placeholder' ] ) { |
|
| 141 | + $placeholder = $args[ 'placeholder' ]; |
|
| 142 | 142 | } else { |
| 143 | 143 | $placeholder = ''; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $disabled = $args['disabled'] ? ' disabled="disabled"' : ''; |
|
| 147 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 148 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( str_replace( '-', '_', $args['id'] ) ) . '" class="gravityview-select ' . $class . '"' . $multiple . $disabled . ' data-placeholder="' . $placeholder . '"'. $data_elements . '>'; |
|
| 146 | + $disabled = $args[ 'disabled' ] ? ' disabled="disabled"' : ''; |
|
| 147 | + $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args[ 'class' ] ) ) ); |
|
| 148 | + $output = '<select name="' . esc_attr( $args[ 'name' ] ) . '" id="' . esc_attr( str_replace( '-', '_', $args[ 'id' ] ) ) . '" class="gravityview-select ' . $class . '"' . $multiple . $disabled . ' data-placeholder="' . $placeholder . '"' . $data_elements . '>'; |
|
| 149 | 149 | |
| 150 | - if ( ! empty( $args['options'] ) ) { |
|
| 150 | + if ( ! empty( $args[ 'options' ] ) ) { |
|
| 151 | 151 | |
| 152 | - if ( $args['show_option_none'] ) { |
|
| 153 | - if( $args['multiple'] ) { |
|
| 154 | - $selected = selected( true, in_array( -1, $args['selected'] ), false ); |
|
| 152 | + if ( $args[ 'show_option_none' ] ) { |
|
| 153 | + if ( $args[ 'multiple' ] ) { |
|
| 154 | + $selected = selected( true, in_array( -1, $args[ 'selected' ] ), false ); |
|
| 155 | 155 | } else { |
| 156 | - $selected = selected( $args['selected'], -1, false ); |
|
| 156 | + $selected = selected( $args[ 'selected' ], -1, false ); |
|
| 157 | 157 | } |
| 158 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 158 | + $output .= '<option value="-1"' . $selected . '>' . esc_html( $args[ 'show_option_none' ] ) . '</option>'; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - foreach( $args['options'] as $key => $option ) { |
|
| 161 | + foreach ( $args[ 'options' ] as $key => $option ) { |
|
| 162 | 162 | |
| 163 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 164 | - $selected = selected( true, in_array( $key, $args['selected'], true ), false ); |
|
| 163 | + if ( $args[ 'multiple' ] && is_array( $args[ 'selected' ] ) ) { |
|
| 164 | + $selected = selected( true, in_array( $key, $args[ 'selected' ], true ), false ); |
|
| 165 | 165 | } else { |
| 166 | - $selected = selected( $args['selected'], $key, false ); |
|
| 166 | + $selected = selected( $args[ 'selected' ], $key, false ); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | function parse_um_profile_post_content( $args = array() ) { |
| 44 | 44 | global $ultimatemember; |
| 45 | 45 | |
| 46 | - if( ! $ultimatemember || ! is_object( $ultimatemember ) || ! class_exists( 'GravityView_View_Data' ) ) { |
|
| 46 | + if ( ! $ultimatemember || ! is_object( $ultimatemember ) || ! class_exists( 'GravityView_View_Data' ) ) { |
|
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // @todo Support Ultimate Member 2.0 - for now, prevent fatal error |
| 51 | - if( ! isset( $ultimatemember->profile ) ) { |
|
| 51 | + if ( ! isset( $ultimatemember->profile ) ) { |
|
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | return; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - GravityView_View_Data::getInstance()->parse_post_content( $active_tab[0]->post_content ); |
|
| 67 | + GravityView_View_Data::getInstance()->parse_post_content( $active_tab[ 0 ]->post_content ); |
|
| 68 | 68 | |
| 69 | 69 | wp_reset_postdata(); |
| 70 | 70 | } |
@@ -44,20 +44,20 @@ discard block |
||
| 44 | 44 | function add_meta_keys_from_post( $meta_keys = array(), $post_id = 0 ) { |
| 45 | 45 | |
| 46 | 46 | // Can never be too careful: double-check that ACF is active and the function exists |
| 47 | - if ( ! function_exists( 'get_field_objects' ) || ! class_exists('acf_field_functions' ) ) { |
|
| 47 | + if ( ! function_exists( 'get_field_objects' ) || ! class_exists( 'acf_field_functions' ) ) { |
|
| 48 | 48 | return $meta_keys; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $acf_field_functions = new acf_field_functions; |
| 52 | 52 | |
| 53 | - remove_action('acf/format_value', array( $acf_field_functions, 'format_value'), 5 ); |
|
| 53 | + remove_action( 'acf/format_value', array( $acf_field_functions, 'format_value' ), 5 ); |
|
| 54 | 54 | |
| 55 | 55 | $acf_keys = get_field_objects( $post_id, array( 'load_value' => false ) ); |
| 56 | 56 | |
| 57 | 57 | // Restore existing filters added by format_value |
| 58 | - add_action('acf/format_value', array( $acf_field_functions, 'format_value'), 5, 3 ); |
|
| 58 | + add_action( 'acf/format_value', array( $acf_field_functions, 'format_value' ), 5, 3 ); |
|
| 59 | 59 | |
| 60 | - if( $acf_keys ) { |
|
| 60 | + if ( $acf_keys ) { |
|
| 61 | 61 | return array_merge( array_keys( $acf_keys ), $meta_keys ); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | * @return void |
| 73 | 73 | */ |
| 74 | 74 | private function fix_posted_fields() { |
| 75 | - if( is_admin() && isset( $_POST['action'] ) && isset( $_POST['post_type'] ) ) { |
|
| 76 | - if( 'editpost' === $_POST['action'] && 'gravityview' === $_POST['post_type'] ) { |
|
| 77 | - $_POST['fields'] = _gravityview_process_posted_fields(); |
|
| 75 | + if ( is_admin() && isset( $_POST[ 'action' ] ) && isset( $_POST[ 'post_type' ] ) ) { |
|
| 76 | + if ( 'editpost' === $_POST[ 'action' ] && 'gravityview' === $_POST[ 'post_type' ] ) { |
|
| 77 | + $_POST[ 'fields' ] = _gravityview_process_posted_fields(); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -24,132 +24,132 @@ |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * Given information provided in an entry, get array of media IDs |
|
| 28 | - * |
|
| 29 | - * This is necessary because GF doesn't expect to need to update post images, only to create them. |
|
| 30 | - * |
|
| 31 | - * @see GFFormsModel::create_post() |
|
| 32 | - * |
|
| 33 | - * @since 1.17 |
|
| 34 | - * |
|
| 35 | - * @param array $form Gravity Forms form array |
|
| 36 | - * @param array $entry Gravity Forms entry array |
|
| 37 | - * |
|
| 38 | - * @return array Array of "Field ID" => "Media IDs" |
|
| 39 | - */ |
|
| 40 | - public static function get_post_field_images( $form, $entry ) { |
|
| 41 | - |
|
| 42 | - $post_data = self::get_post_fields( $form, $entry ); |
|
| 43 | - |
|
| 44 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
| 45 | - |
|
| 46 | - $post_images = array(); |
|
| 47 | - |
|
| 48 | - foreach ( $media as $media_item ) { |
|
| 49 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
| 50 | - if( |
|
| 51 | - rgar( $post_data_item, 'title' ) === $media_item->post_title && |
|
| 52 | - rgar( $post_data_item, 'description' ) === $media_item->post_content && |
|
| 53 | - rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
|
| 54 | - ) { |
|
| 55 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - return $post_images; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Alias of GFFormsModel::get_post_fields(); just making it public |
|
| 65 | - * |
|
| 66 | - * @see GFFormsModel::get_post_fields() |
|
| 67 | - * |
|
| 68 | - * @since 1.17 |
|
| 69 | - * |
|
| 70 | - * @param array $form Gravity Forms form array |
|
| 71 | - * @param array $entry Gravity Forms entry array |
|
| 72 | - * |
|
| 73 | - * @return array |
|
| 74 | - */ |
|
| 75 | - public static function get_post_fields( $form, $entry ) { |
|
| 76 | - |
|
| 77 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' ); |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * If the method changes to public, use Gravity Forms' method |
|
| 81 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
| 82 | - */ |
|
| 83 | - if( $reflection->isPublic() ) { |
|
| 84 | - return parent::get_post_fields( $form, $entry ); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // It was private; let's make it public |
|
| 88 | - $reflection->setAccessible( true ); |
|
| 89 | - |
|
| 90 | - return $reflection->invoke( new GFFormsModel, $form, $entry ); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
| 95 | - * |
|
| 96 | - * @since 1.16.2 |
|
| 97 | - * |
|
| 98 | - * @param string $url URL of the post image to update |
|
| 99 | - * @param int $post_id ID of the post image to update |
|
| 100 | - * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
| 101 | - */ |
|
| 102 | - public static function copy_post_image( $url, $post_id ) { |
|
| 103 | - |
|
| 104 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * If the method changes to public, use Gravity Forms' method |
|
| 108 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
| 109 | - */ |
|
| 110 | - if( $reflection->isPublic() ) { |
|
| 111 | - return parent::copy_post_image( $url, $post_id ); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - // It was private; let's make it public |
|
| 115 | - $reflection->setAccessible( true ); |
|
| 116 | - |
|
| 117 | - return $reflection->invoke( new GFFormsModel, $url, $post_id ); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
| 122 | - * |
|
| 123 | - * Note: The method became public in GF 1.9.17.7 |
|
| 124 | - * |
|
| 125 | - * @see GFFormsModel::media_handle_upload |
|
| 126 | - * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
| 127 | - * |
|
| 128 | - * @uses copy_post_image |
|
| 129 | - * @uses wp_insert_attachment |
|
| 130 | - * @uses wp_update_attachment_metadata |
|
| 131 | - * |
|
| 132 | - * @param string $url URL of the post image to update |
|
| 133 | - * @param int $post_id ID of the post image to update |
|
| 134 | - * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys. |
|
| 135 | - * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
| 136 | - */ |
|
| 137 | - public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
| 138 | - |
|
| 139 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * If the method changes to public, use Gravity Forms' method |
|
| 143 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
| 144 | - */ |
|
| 145 | - if( $reflection->isPublic() ) { |
|
| 146 | - return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - // It was private; let's make it public |
|
| 150 | - $reflection->setAccessible( true ); |
|
| 151 | - |
|
| 152 | - return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data ); |
|
| 153 | - } |
|
| 27 | + * Given information provided in an entry, get array of media IDs |
|
| 28 | + * |
|
| 29 | + * This is necessary because GF doesn't expect to need to update post images, only to create them. |
|
| 30 | + * |
|
| 31 | + * @see GFFormsModel::create_post() |
|
| 32 | + * |
|
| 33 | + * @since 1.17 |
|
| 34 | + * |
|
| 35 | + * @param array $form Gravity Forms form array |
|
| 36 | + * @param array $entry Gravity Forms entry array |
|
| 37 | + * |
|
| 38 | + * @return array Array of "Field ID" => "Media IDs" |
|
| 39 | + */ |
|
| 40 | + public static function get_post_field_images( $form, $entry ) { |
|
| 41 | + |
|
| 42 | + $post_data = self::get_post_fields( $form, $entry ); |
|
| 43 | + |
|
| 44 | + $media = get_attached_media( 'image', $entry['post_id'] ); |
|
| 45 | + |
|
| 46 | + $post_images = array(); |
|
| 47 | + |
|
| 48 | + foreach ( $media as $media_item ) { |
|
| 49 | + foreach( (array) $post_data['images'] as $post_data_item ) { |
|
| 50 | + if( |
|
| 51 | + rgar( $post_data_item, 'title' ) === $media_item->post_title && |
|
| 52 | + rgar( $post_data_item, 'description' ) === $media_item->post_content && |
|
| 53 | + rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
|
| 54 | + ) { |
|
| 55 | + $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + return $post_images; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Alias of GFFormsModel::get_post_fields(); just making it public |
|
| 65 | + * |
|
| 66 | + * @see GFFormsModel::get_post_fields() |
|
| 67 | + * |
|
| 68 | + * @since 1.17 |
|
| 69 | + * |
|
| 70 | + * @param array $form Gravity Forms form array |
|
| 71 | + * @param array $entry Gravity Forms entry array |
|
| 72 | + * |
|
| 73 | + * @return array |
|
| 74 | + */ |
|
| 75 | + public static function get_post_fields( $form, $entry ) { |
|
| 76 | + |
|
| 77 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' ); |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * If the method changes to public, use Gravity Forms' method |
|
| 81 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
| 82 | + */ |
|
| 83 | + if( $reflection->isPublic() ) { |
|
| 84 | + return parent::get_post_fields( $form, $entry ); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // It was private; let's make it public |
|
| 88 | + $reflection->setAccessible( true ); |
|
| 89 | + |
|
| 90 | + return $reflection->invoke( new GFFormsModel, $form, $entry ); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
| 95 | + * |
|
| 96 | + * @since 1.16.2 |
|
| 97 | + * |
|
| 98 | + * @param string $url URL of the post image to update |
|
| 99 | + * @param int $post_id ID of the post image to update |
|
| 100 | + * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
| 101 | + */ |
|
| 102 | + public static function copy_post_image( $url, $post_id ) { |
|
| 103 | + |
|
| 104 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * If the method changes to public, use Gravity Forms' method |
|
| 108 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
| 109 | + */ |
|
| 110 | + if( $reflection->isPublic() ) { |
|
| 111 | + return parent::copy_post_image( $url, $post_id ); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + // It was private; let's make it public |
|
| 115 | + $reflection->setAccessible( true ); |
|
| 116 | + |
|
| 117 | + return $reflection->invoke( new GFFormsModel, $url, $post_id ); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
| 122 | + * |
|
| 123 | + * Note: The method became public in GF 1.9.17.7 |
|
| 124 | + * |
|
| 125 | + * @see GFFormsModel::media_handle_upload |
|
| 126 | + * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
| 127 | + * |
|
| 128 | + * @uses copy_post_image |
|
| 129 | + * @uses wp_insert_attachment |
|
| 130 | + * @uses wp_update_attachment_metadata |
|
| 131 | + * |
|
| 132 | + * @param string $url URL of the post image to update |
|
| 133 | + * @param int $post_id ID of the post image to update |
|
| 134 | + * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys. |
|
| 135 | + * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
| 136 | + */ |
|
| 137 | + public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
| 138 | + |
|
| 139 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * If the method changes to public, use Gravity Forms' method |
|
| 143 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
| 144 | + */ |
|
| 145 | + if( $reflection->isPublic() ) { |
|
| 146 | + return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + // It was private; let's make it public |
|
| 150 | + $reflection->setAccessible( true ); |
|
| 151 | + |
|
| 152 | + return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data ); |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | 155 | } |
| 156 | 156 | \ No newline at end of file |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | public static function is_value_match( $field_value, $target_value, $operation = 'is', $source_field = null, $rule = null, $form = null ) { |
| 41 | 41 | |
| 42 | 42 | if ( 'date_created' === $source_field ) { |
| 43 | - $field_value = is_int( $field_value )? $field_value : strtotime( $field_value ); |
|
| 44 | - $target_value = is_int( $target_value )? $target_value : strtotime( $target_value ); |
|
| 43 | + $field_value = is_int( $field_value ) ? $field_value : strtotime( $field_value ); |
|
| 44 | + $target_value = is_int( $target_value ) ? $target_value : strtotime( $target_value ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | return parent::is_value_match( $field_value, $target_value, $operation, $source_field, $rule, $form ); // TODO: Change the autogenerated stub |
@@ -65,18 +65,18 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $post_data = self::get_post_fields( $form, $entry ); |
| 67 | 67 | |
| 68 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
| 68 | + $media = get_attached_media( 'image', $entry[ 'post_id' ] ); |
|
| 69 | 69 | |
| 70 | 70 | $post_images = array(); |
| 71 | 71 | |
| 72 | 72 | foreach ( $media as $media_item ) { |
| 73 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
| 74 | - if( |
|
| 73 | + foreach ( (array)$post_data[ 'images' ] as $post_data_item ) { |
|
| 74 | + if ( |
|
| 75 | 75 | rgar( $post_data_item, 'title' ) === $media_item->post_title && |
| 76 | 76 | rgar( $post_data_item, 'description' ) === $media_item->post_content && |
| 77 | 77 | rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
| 78 | 78 | ) { |
| 79 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
| 79 | + $post_images[ "{$post_data_item[ 'field_id' ]}" ] = $media_item->ID; |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * If the method changes to public, use Gravity Forms' method |
| 105 | 105 | * @todo: If/when the method is public, remove the unneeded copied code. |
| 106 | 106 | */ |
| 107 | - if( $reflection->isPublic() ) { |
|
| 107 | + if ( $reflection->isPublic() ) { |
|
| 108 | 108 | return parent::get_post_fields( $form, $entry ); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * If the method changes to public, use Gravity Forms' method |
| 132 | 132 | * @todo: If/when the method is public, remove the unneeded copied code. |
| 133 | 133 | */ |
| 134 | - if( $reflection->isPublic() ) { |
|
| 134 | + if ( $reflection->isPublic() ) { |
|
| 135 | 135 | return parent::copy_post_image( $url, $post_id ); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * If the method changes to public, use Gravity Forms' method |
| 167 | 167 | * @todo: If/when the method is public, remove the unneeded copied code. |
| 168 | 168 | */ |
| 169 | - if( $reflection->isPublic() ) { |
|
| 169 | + if ( $reflection->isPublic() ) { |
|
| 170 | 170 | return parent::media_handle_upload( $url, $post_id, $post_data ); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | $tables = array(); |
| 43 | 43 | |
| 44 | 44 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) ) { |
| 45 | - $tables []= GFFormsModel::get_entry_meta_table_name(); |
|
| 45 | + $tables [ ] = GFFormsModel::get_entry_meta_table_name(); |
|
| 46 | 46 | } |
| 47 | - $tables []= GFFormsModel::get_lead_meta_table_name(); |
|
| 47 | + $tables [ ] = GFFormsModel::get_lead_meta_table_name(); |
|
| 48 | 48 | |
| 49 | 49 | $suppress = $wpdb->suppress_errors(); |
| 50 | 50 | foreach ( $tables as $meta_table ) { |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | $tables = array(); |
| 71 | 71 | |
| 72 | 72 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_notes_table_name' ) ) { |
| 73 | - $tables[] = GFFormsModel::get_entry_notes_table_name(); |
|
| 73 | + $tables[ ] = GFFormsModel::get_entry_notes_table_name(); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $tables[] = GFFormsModel::get_lead_notes_table_name(); |
|
| 76 | + $tables[ ] = GFFormsModel::get_lead_notes_table_name(); |
|
| 77 | 77 | |
| 78 | - $disapproved = __('Disapproved the Entry for GravityView', 'gravityview'); |
|
| 79 | - $approved = __('Approved the Entry for GravityView', 'gravityview'); |
|
| 78 | + $disapproved = __( 'Disapproved the Entry for GravityView', 'gravityview' ); |
|
| 79 | + $approved = __( 'Approved the Entry for GravityView', 'gravityview' ); |
|
| 80 | 80 | |
| 81 | 81 | $suppress = $wpdb->suppress_errors(); |
| 82 | 82 | foreach ( $tables as $notes_table ) { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $default_settings = array( |
| 36 | 36 | 'id' => array( |
| 37 | - 'label' => __('View ID', 'gravityview'), |
|
| 37 | + 'label' => __( 'View ID', 'gravityview' ), |
|
| 38 | 38 | 'type' => 'number', |
| 39 | 39 | 'group' => 'default', |
| 40 | 40 | 'value' => NULL, |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | 'show_in_shortcode' => false, |
| 43 | 43 | ), |
| 44 | 44 | 'page_size' => array( |
| 45 | - 'label' => __('Number of entries per page', 'gravityview'), |
|
| 45 | + 'label' => __( 'Number of entries per page', 'gravityview' ), |
|
| 46 | 46 | 'type' => 'number', |
| 47 | 47 | 'class' => 'small-text', |
| 48 | 48 | 'group' => 'default', |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'show_in_shortcode' => true, |
| 51 | 51 | ), |
| 52 | 52 | 'offset' => array( |
| 53 | - 'label' => __('Offset entries starting from', 'gravityview'), |
|
| 53 | + 'label' => __( 'Offset entries starting from', 'gravityview' ), |
|
| 54 | 54 | 'type' => 'number', |
| 55 | 55 | 'class' => 'small-text', |
| 56 | 56 | 'group' => 'default', |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | ), |
| 75 | 75 | 'admin_show_all_statuses' => array( |
| 76 | 76 | 'label' => __( 'Show all entries to administrators', 'gravityview' ), |
| 77 | - 'desc' => __('Administrators will be able to see entries with any approval status.', 'gravityview'), |
|
| 78 | - 'tooltip' => __('Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview'), |
|
| 77 | + 'desc' => __( 'Administrators will be able to see entries with any approval status.', 'gravityview' ), |
|
| 78 | + 'tooltip' => __( 'Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview' ), |
|
| 79 | 79 | 'requires' => 'show_only_approved', |
| 80 | 80 | 'type' => 'checkbox', |
| 81 | 81 | 'group' => 'default', |
@@ -100,40 +100,40 @@ discard block |
||
| 100 | 100 | 'user_edit' => array( |
| 101 | 101 | 'label' => __( 'Allow User Edit', 'gravityview' ), |
| 102 | 102 | 'group' => 'default', |
| 103 | - 'desc' => __('Allow logged-in users to edit entries they created.', 'gravityview'), |
|
| 103 | + 'desc' => __( 'Allow logged-in users to edit entries they created.', 'gravityview' ), |
|
| 104 | 104 | 'value' => 0, |
| 105 | - 'tooltip' => __('Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview'), |
|
| 105 | + 'tooltip' => __( 'Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview' ), |
|
| 106 | 106 | 'type' => 'checkbox', |
| 107 | 107 | 'show_in_shortcode' => true, |
| 108 | 108 | ), |
| 109 | 109 | 'user_delete' => array( |
| 110 | 110 | 'label' => __( 'Allow User Delete', 'gravityview' ), |
| 111 | 111 | 'group' => 'default', |
| 112 | - 'desc' => __('Allow logged-in users to delete entries they created.', 'gravityview'), |
|
| 112 | + 'desc' => __( 'Allow logged-in users to delete entries they created.', 'gravityview' ), |
|
| 113 | 113 | 'value' => 0, |
| 114 | - 'tooltip' => __('Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview'), |
|
| 114 | + 'tooltip' => __( 'Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview' ), |
|
| 115 | 115 | 'type' => 'checkbox', |
| 116 | 116 | 'show_in_shortcode' => true, |
| 117 | 117 | ), |
| 118 | 118 | 'sort_field' => array( |
| 119 | - 'label' => __('Sort by field', 'gravityview'), |
|
| 119 | + 'label' => __( 'Sort by field', 'gravityview' ), |
|
| 120 | 120 | 'type' => 'select', |
| 121 | 121 | 'value' => '', |
| 122 | 122 | 'group' => 'sort', |
| 123 | 123 | 'options' => array( |
| 124 | - '' => __( 'Default', 'gravityview'), |
|
| 125 | - 'date_created' => __( 'Date Created', 'gravityview'), |
|
| 124 | + '' => __( 'Default', 'gravityview' ), |
|
| 125 | + 'date_created' => __( 'Date Created', 'gravityview' ), |
|
| 126 | 126 | ), |
| 127 | 127 | 'show_in_shortcode' => true, |
| 128 | 128 | ), |
| 129 | 129 | 'sort_direction' => array( |
| 130 | - 'label' => __('Sort direction', 'gravityview'), |
|
| 130 | + 'label' => __( 'Sort direction', 'gravityview' ), |
|
| 131 | 131 | 'type' => 'select', |
| 132 | 132 | 'value' => 'ASC', |
| 133 | 133 | 'group' => 'sort', |
| 134 | 134 | 'options' => array( |
| 135 | - 'ASC' => __('ASC', 'gravityview'), |
|
| 136 | - 'DESC' => __('DESC', 'gravityview'), |
|
| 135 | + 'ASC' => __( 'ASC', 'gravityview' ), |
|
| 136 | + 'DESC' => __( 'DESC', 'gravityview' ), |
|
| 137 | 137 | ), |
| 138 | 138 | 'show_in_shortcode' => true, |
| 139 | 139 | ), |
@@ -148,69 +148,69 @@ discard block |
||
| 148 | 148 | 'show_in_template' => array( 'default_table', 'preset_business_data', 'preset_issue_tracker', 'preset_resume_board', 'preset_job_board' ), |
| 149 | 149 | ), |
| 150 | 150 | 'start_date' => array( |
| 151 | - 'label' => __('Filter by Start Date', 'gravityview'), |
|
| 151 | + 'label' => __( 'Filter by Start Date', 'gravityview' ), |
|
| 152 | 152 | 'class' => 'gv-datepicker', |
| 153 | - 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
| 153 | + 'desc' => __( 'Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
| 154 | 154 | 'type' => 'text', |
| 155 | 155 | 'value' => '', |
| 156 | 156 | 'group' => 'filter', |
| 157 | 157 | 'show_in_shortcode' => true, |
| 158 | 158 | ), |
| 159 | 159 | 'end_date' => array( |
| 160 | - 'label' => __('Filter by End Date', 'gravityview'), |
|
| 160 | + 'label' => __( 'Filter by End Date', 'gravityview' ), |
|
| 161 | 161 | 'class' => 'gv-datepicker', |
| 162 | - 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
| 162 | + 'desc' => __( 'Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
| 163 | 163 | 'type' => 'text', |
| 164 | 164 | 'value' => '', |
| 165 | 165 | 'group' => 'filter', |
| 166 | 166 | 'show_in_shortcode' => true, |
| 167 | 167 | ), |
| 168 | 168 | 'class' => array( |
| 169 | - 'label' => __('CSS Class', 'gravityview'), |
|
| 170 | - 'desc' => __('CSS class to add to the wrapping HTML container.', 'gravityview'), |
|
| 169 | + 'label' => __( 'CSS Class', 'gravityview' ), |
|
| 170 | + 'desc' => __( 'CSS class to add to the wrapping HTML container.', 'gravityview' ), |
|
| 171 | 171 | 'group' => 'default', |
| 172 | 172 | 'type' => 'text', |
| 173 | 173 | 'value' => '', |
| 174 | 174 | 'show_in_shortcode' => false, |
| 175 | 175 | ), |
| 176 | 176 | 'search_value' => array( |
| 177 | - 'label' => __('Search Value', 'gravityview'), |
|
| 178 | - 'desc' => __('Define a default search value for the View', 'gravityview'), |
|
| 177 | + 'label' => __( 'Search Value', 'gravityview' ), |
|
| 178 | + 'desc' => __( 'Define a default search value for the View', 'gravityview' ), |
|
| 179 | 179 | 'type' => 'text', |
| 180 | 180 | 'value' => '', |
| 181 | 181 | 'group' => 'filter', |
| 182 | 182 | 'show_in_shortcode' => false, |
| 183 | 183 | ), |
| 184 | 184 | 'search_field' => array( |
| 185 | - 'label' => __('Search Field', 'gravityview'), |
|
| 186 | - 'desc' => __('If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview'), |
|
| 185 | + 'label' => __( 'Search Field', 'gravityview' ), |
|
| 186 | + 'desc' => __( 'If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview' ), |
|
| 187 | 187 | 'type' => 'number', |
| 188 | 188 | 'value' => '', |
| 189 | 189 | 'group' => 'filter', |
| 190 | 190 | 'show_in_shortcode' => false, |
| 191 | 191 | ), |
| 192 | 192 | 'single_title' => array( |
| 193 | - 'label' => __('Single Entry Title', 'gravityview'), |
|
| 193 | + 'label' => __( 'Single Entry Title', 'gravityview' ), |
|
| 194 | 194 | 'type' => 'text', |
| 195 | - 'desc' => __('When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview'), |
|
| 195 | + 'desc' => __( 'When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview' ), |
|
| 196 | 196 | 'group' => 'default', |
| 197 | 197 | 'value' => '', |
| 198 | 198 | 'show_in_shortcode' => false, |
| 199 | 199 | 'full_width' => true, |
| 200 | 200 | ), |
| 201 | 201 | 'back_link_label' => array( |
| 202 | - 'label' => __('Back Link Label', 'gravityview'), |
|
| 202 | + 'label' => __( 'Back Link Label', 'gravityview' ), |
|
| 203 | 203 | 'group' => 'default', |
| 204 | - 'desc' => __('The text of the link that returns to the multiple entries view.', 'gravityview'), |
|
| 204 | + 'desc' => __( 'The text of the link that returns to the multiple entries view.', 'gravityview' ), |
|
| 205 | 205 | 'type' => 'text', |
| 206 | 206 | 'value' => '', |
| 207 | 207 | 'show_in_shortcode' => false, |
| 208 | 208 | 'full_width' => true, |
| 209 | 209 | ), |
| 210 | 210 | 'embed_only' => array( |
| 211 | - 'label' => __('Prevent Direct Access', 'gravityview'), |
|
| 211 | + 'label' => __( 'Prevent Direct Access', 'gravityview' ), |
|
| 212 | 212 | 'group' => 'default', |
| 213 | - 'desc' => __('Only allow access to this View when embedded using the shortcode.', 'gravityview'), |
|
| 213 | + 'desc' => __( 'Only allow access to this View when embedded using the shortcode.', 'gravityview' ), |
|
| 214 | 214 | 'type' => 'checkbox', |
| 215 | 215 | 'value' => '', |
| 216 | 216 | 'tooltip' => false, |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | ); |
| 226 | 226 | |
| 227 | 227 | if ( version_compare( \GFCommon::$version, '2.3-beta-4', '>=' ) ) { |
| 228 | - $default_settings['sort_direction']['options']['RAND'] = __( 'Random', 'gravityview' ); |
|
| 228 | + $default_settings[ 'sort_direction' ][ 'options' ][ 'RAND' ] = __( 'Random', 'gravityview' ); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -245,19 +245,19 @@ discard block |
||
| 245 | 245 | // By default, we only want the key => value pairing, not the whole array. |
| 246 | 246 | if ( ! $detailed ) { |
| 247 | 247 | $defaults = array(); |
| 248 | - foreach( $default_settings as $key => $value ) { |
|
| 249 | - $defaults[ $key ] = $value['value']; |
|
| 248 | + foreach ( $default_settings as $key => $value ) { |
|
| 249 | + $defaults[ $key ] = $value[ 'value' ]; |
|
| 250 | 250 | } |
| 251 | 251 | return $defaults; |
| 252 | 252 | |
| 253 | 253 | // But sometimes, we want all the details. |
| 254 | 254 | } else { |
| 255 | - foreach ($default_settings as $key => $value) { |
|
| 255 | + foreach ( $default_settings as $key => $value ) { |
|
| 256 | 256 | |
| 257 | 257 | // If the $group argument is set for the method, |
| 258 | 258 | // ignore any settings that aren't in that group. |
| 259 | 259 | if ( ! empty( $group ) && is_string( $group ) ) { |
| 260 | - if ( empty( $value['group'] ) || $value['group'] !== $group ) { |
|
| 260 | + if ( empty( $value[ 'group' ] ) || $value[ 'group' ] !== $group ) { |
|
| 261 | 261 | unset( $default_settings[ $key ] ); |
| 262 | 262 | } |
| 263 | 263 | } |