Complex classes like GravityView_frontend often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use GravityView_frontend, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
15 | class GravityView_frontend { |
||
|
|||
16 | |||
17 | /** |
||
18 | * Regex strings that are used to determine whether the current request is a GravityView search or not. |
||
19 | * @see GravityView_frontend::is_searching() |
||
20 | * @since 1.7.4.1 |
||
21 | * @var array |
||
22 | */ |
||
23 | private static $search_parameters = array( 'gv_search', 'gv_start', 'gv_end', 'gv_id', 'gv_by', 'filter_*' ); |
||
24 | |||
25 | /** |
||
26 | * Is the currently viewed post a `gravityview` post type? |
||
27 | * @var boolean |
||
28 | */ |
||
29 | var $is_gravityview_post_type = false; |
||
30 | |||
31 | /** |
||
32 | * Does the current post have a `[gravityview]` shortcode? |
||
33 | * @var boolean |
||
34 | */ |
||
35 | var $post_has_shortcode = false; |
||
36 | |||
37 | /** |
||
38 | * The Post ID of the currently viewed post. Not necessarily GV |
||
39 | * @var int |
||
40 | */ |
||
41 | var $post_id = null; |
||
42 | |||
43 | /** |
||
44 | * Are we currently viewing a single entry? |
||
45 | * If so, the int value of the entry ID. Otherwise, false. |
||
46 | * @var int|boolean |
||
47 | */ |
||
48 | var $single_entry = false; |
||
49 | |||
50 | /** |
||
51 | * If we are viewing a single entry, the entry data |
||
52 | * @var array|false |
||
53 | */ |
||
54 | var $entry = false; |
||
55 | |||
56 | /** |
||
57 | * When displaying the single entry we should always know to which View it belongs (the context is everything!) |
||
58 | * @var null |
||
59 | */ |
||
60 | var $context_view_id = null; |
||
61 | |||
62 | /** |
||
63 | * The View is showing search results |
||
64 | * @since 1.5.4 |
||
65 | * @var boolean |
||
66 | */ |
||
67 | var $is_search = false; |
||
68 | |||
69 | /** |
||
70 | * The view data parsed from the $post |
||
71 | * |
||
72 | * @see GravityView_View_Data::__construct() |
||
73 | * @var GravityView_View_Data |
||
74 | */ |
||
75 | var $gv_output_data = null; |
||
76 | |||
77 | /** |
||
78 | * @var GravityView_frontend |
||
79 | */ |
||
80 | static $instance; |
||
81 | |||
82 | /** |
||
83 | * Class constructor, enforce Singleton pattern |
||
84 | */ |
||
85 | private function __construct() {} |
||
86 | |||
87 | 39 | private function initialize() { |
|
103 | |||
104 | /** |
||
105 | * Get the one true instantiated self |
||
106 | * @return GravityView_frontend |
||
107 | */ |
||
108 | 42 | public static function getInstance() { |
|
117 | |||
118 | /** |
||
119 | * @return GravityView_View_Data |
||
120 | */ |
||
121 | 40 | public function getGvOutputData() { |
|
124 | |||
125 | /** |
||
126 | * @param \GravityView_View_Data $gv_output_data |
||
127 | */ |
||
128 | 40 | public function setGvOutputData( $gv_output_data ) { |
|
131 | |||
132 | /** |
||
133 | * @return boolean |
||
134 | */ |
||
135 | 39 | public function isSearch() { |
|
138 | |||
139 | /** |
||
140 | * @param boolean $is_search |
||
141 | */ |
||
142 | 40 | public function setIsSearch( $is_search ) { |
|
145 | |||
146 | /** |
||
147 | * @return bool|int |
||
148 | */ |
||
149 | 41 | public function getSingleEntry() { |
|
152 | |||
153 | /** |
||
154 | * Sets the single entry ID and also the entry |
||
155 | * @param bool|int|string $single_entry |
||
156 | */ |
||
157 | 39 | public function setSingleEntry( $single_entry ) { |
|
162 | |||
163 | /** |
||
164 | * @return array |
||
165 | */ |
||
166 | 39 | public function getEntry() { |
|
169 | |||
170 | /** |
||
171 | * Set the current entry |
||
172 | * @param array|int $entry Entry array or entry slug or ID |
||
173 | */ |
||
174 | 39 | public function setEntry( $entry ) { |
|
182 | |||
183 | /** |
||
184 | * @return int |
||
185 | */ |
||
186 | 40 | public function getPostId() { |
|
189 | |||
190 | /** |
||
191 | * @param int $post_id |
||
192 | */ |
||
193 | 40 | public function setPostId( $post_id ) { |
|
196 | |||
197 | /** |
||
198 | * @return boolean |
||
199 | */ |
||
200 | 41 | public function isPostHasShortcode() { |
|
203 | |||
204 | /** |
||
205 | * @param boolean $post_has_shortcode |
||
206 | */ |
||
207 | 40 | public function setPostHasShortcode( $post_has_shortcode ) { |
|
210 | |||
211 | /** |
||
212 | * @return boolean |
||
213 | */ |
||
214 | 42 | public function isGravityviewPostType() { |
|
217 | |||
218 | /** |
||
219 | * @param boolean $is_gravityview_post_type |
||
220 | */ |
||
221 | 40 | public function setIsGravityviewPostType( $is_gravityview_post_type ) { |
|
224 | |||
225 | /** |
||
226 | * Set the context view ID used when page contains multiple embedded views or displaying the single entry view |
||
227 | * |
||
228 | * |
||
229 | * |
||
230 | * @param null $view_id |
||
231 | */ |
||
232 | 3 | public function set_context_view_id( $view_id = null ) { |
|
253 | |||
254 | /** |
||
255 | * Returns the the view_id context when page contains multiple embedded views or displaying single entry view |
||
256 | * |
||
257 | * @since 1.5.4 |
||
258 | * |
||
259 | * @return int|null |
||
260 | */ |
||
261 | 39 | public function get_context_view_id() { |
|
264 | |||
265 | /** |
||
266 | * Allow GravityView entry endpoints on the front page of a site |
||
267 | * |
||
268 | * @link https://core.trac.wordpress.org/ticket/23867 Fixes this core issue |
||
269 | * @link https://wordpress.org/plugins/cpt-on-front-page/ Code is based on this |
||
270 | * |
||
271 | * @since 1.17.3 |
||
272 | * |
||
273 | * @param WP_Query &$query (passed by reference) |
||
274 | * |
||
275 | * @return void |
||
276 | */ |
||
277 | 188 | public function parse_query_fix_frontpage( &$query ) { |
|
331 | |||
332 | /** |
||
333 | * Read the $post and process the View data inside |
||
334 | * @param array $wp Passed in the `wp` hook. Not used. |
||
335 | * @return void |
||
336 | */ |
||
337 | 2 | public function parse_content( $wp = array() ) { |
|
338 | 2 | global $post; |
|
339 | |||
340 | // If in admin and NOT AJAX request, get outta here. |
||
341 | 2 | if ( gravityview()->request->is_admin() ) { |
|
342 | return; |
||
343 | } |
||
344 | |||
345 | // Calculate requested Views |
||
346 | 2 | $this->setGvOutputData( GravityView_View_Data::getInstance( $post ) ); |
|
347 | |||
348 | // !important: we need to run this before getting single entry (to kick the advanced filter) |
||
349 | 2 | $this->set_context_view_id(); |
|
350 | |||
351 | 2 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
|
352 | |||
353 | 2 | $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
354 | 2 | $this->setPostId( $post_id ); |
|
355 | 2 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
|
356 | 2 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
|
357 | |||
358 | // check if the View is showing search results (only for multiple entries View) |
||
359 | 2 | $this->setIsSearch( $this->is_searching() ); |
|
360 | |||
361 | 2 | unset( $entry, $post_id, $post_has_shortcode ); |
|
362 | 2 | } |
|
363 | |||
364 | /** |
||
365 | * Set the entry |
||
366 | */ |
||
367 | function set_entry_data() { |
||
372 | |||
373 | /** |
||
374 | * Checks if the current View is presenting search results |
||
375 | * |
||
376 | * @since 1.5.4 |
||
377 | * |
||
378 | * @return boolean True: Yes, it's a search; False: No, not a search. |
||
379 | */ |
||
380 | 2 | function is_searching() { |
|
422 | |||
423 | /** |
||
424 | * Filter the title for the single entry view |
||
425 | * |
||
426 | * @param string $passed_title Current title |
||
427 | * @param int $passed_post_id Post ID |
||
428 | * @return string (modified) title |
||
429 | */ |
||
430 | 9 | public function single_entry_title( $passed_title, $passed_post_id = null ) { |
|
500 | |||
501 | /** |
||
502 | * Returns the single entry title for a View with variables replaced and shortcodes parsed |
||
503 | * |
||
504 | * @since 2.7.2 |
||
505 | * |
||
506 | * @param \GV\View|null $view |
||
507 | * @param array $entry |
||
508 | * @param string $passed_title |
||
509 | * |
||
510 | * @return string |
||
511 | */ |
||
512 | private function _get_single_entry_title( $view, $entry = array(), $passed_title = '' ) { |
||
548 | |||
549 | |||
550 | /** |
||
551 | * In case View post is called directly, insert the view in the post content |
||
552 | * |
||
553 | * @deprecated Use \GV\View::content() instead. |
||
554 | * |
||
555 | * @access public |
||
556 | * @static |
||
557 | * @param mixed $content |
||
558 | * @return string Add the View output into View CPT content |
||
559 | */ |
||
560 | 4 | public function insert_view_in_content( $content ) { |
|
564 | |||
565 | /** |
||
566 | * Disable comments on GravityView post types |
||
567 | * @param boolean $open existing status |
||
568 | * @param int $post_id Post ID |
||
569 | * @return boolean |
||
570 | */ |
||
571 | public function comments_open( $open, $post_id ) { |
||
587 | |||
588 | /** |
||
589 | * Display a warning when a View has not been configured |
||
590 | * |
||
591 | * @since 1.19.2 |
||
592 | * |
||
593 | * @param int $view_id The ID of the View currently being displayed |
||
594 | * |
||
595 | * @return void |
||
596 | */ |
||
597 | 2 | public function context_not_configured_warning( $view_id = 0 ) { |
|
635 | |||
636 | |||
637 | /** |
||
638 | * Core function to render a View based on a set of arguments |
||
639 | * |
||
640 | * @access public |
||
641 | * @static |
||
642 | * @param array $passed_args { |
||
643 | * |
||
644 | * Settings for rendering the View |
||
645 | * |
||
646 | * @type int $id View id |
||
647 | * @type int $page_size Number of entries to show per page |
||
648 | * @type string $sort_field Form field id to sort |
||
649 | * @type string $sort_direction Sorting direction ('ASC', 'DESC', or 'RAND') |
||
650 | * @type string $start_date - Ymd |
||
651 | * @type string $end_date - Ymd |
||
652 | * @type string $class - assign a html class to the view |
||
653 | * @type string $offset (optional) - This is the start point in the current data set (0 index based). |
||
654 | * } |
||
655 | * |
||
656 | * @deprecated Use \GV\View_Renderer |
||
657 | * |
||
658 | * @return string|null HTML output of a View, NULL if View isn't found |
||
659 | */ |
||
660 | 1 | public function render_view( $passed_args ) { |
|
685 | |||
686 | /** |
||
687 | * Process the start and end dates for a view - overrides values defined in shortcode (if needed) |
||
688 | * |
||
689 | * The `start_date` and `end_date` keys need to be in a format processable by GFFormsModel::get_date_range_where(), |
||
690 | * which uses \DateTime() format. |
||
691 | * |
||
692 | * You can set the `start_date` or `end_date` to any value allowed by {@link http://www.php.net//manual/en/function.strtotime.php strtotime()}, |
||
693 | * including strings like "now" or "-1 year" or "-3 days". |
||
694 | * |
||
695 | * @see GFFormsModel::get_date_range_where |
||
696 | * |
||
697 | * @param array $args View settings |
||
698 | * @param array $search_criteria Search being performed, if any |
||
699 | * @return array Modified `$search_criteria` array |
||
700 | */ |
||
701 | 77 | public static function process_search_dates( $args, $search_criteria = array() ) { |
|
767 | |||
768 | |||
769 | /** |
||
770 | * Process the approved only search criteria according to the View settings |
||
771 | * |
||
772 | * @param array $args View settings |
||
773 | * @param array $search_criteria Search being performed, if any |
||
774 | * @return array Modified `$search_criteria` array |
||
775 | */ |
||
776 | 76 | public static function process_search_only_approved( $args, $search_criteria ) { |
|
798 | |||
799 | |||
800 | /** |
||
801 | * Check if a certain entry is approved. |
||
802 | * |
||
803 | * If we pass the View settings ($args) it will check the 'show_only_approved' setting before |
||
804 | * checking the entry approved field, returning true if show_only_approved = false. |
||
805 | * |
||
806 | * @since 1.7 |
||
807 | * @since 1.18 Converted check to use GravityView_Entry_Approval_Status::is_approved |
||
808 | * |
||
809 | * @uses GravityView_Entry_Approval_Status::is_approved |
||
810 | * |
||
811 | * @param array $entry Entry object |
||
812 | * @param array $args View settings (optional) |
||
813 | * |
||
814 | * @return bool |
||
815 | */ |
||
816 | public static function is_entry_approved( $entry, $args = array() ) { |
||
833 | |||
834 | /** |
||
835 | * Parse search criteria for a entries search. |
||
836 | * |
||
837 | * array( |
||
838 | * 'search_field' => 1, // ID of the field |
||
839 | * 'search_value' => '', // Value of the field to search |
||
840 | * 'search_operator' => 'contains', // 'is', 'isnot', '>', '<', 'contains' |
||
841 | * 'show_only_approved' => 0 or 1 // Boolean |
||
842 | * ) |
||
843 | * |
||
844 | * @param array $args Array of args |
||
845 | * @param int $form_id Gravity Forms form ID |
||
846 | * @return array Array of search parameters, formatted in Gravity Forms mode, using `status` key set to "active" by default, `field_filters` array with `key`, `value` and `operator` keys. |
||
847 | */ |
||
848 | 77 | public static function get_search_criteria( $args, $form_id ) { |
|
910 | |||
911 | |||
912 | |||
913 | /** |
||
914 | * Core function to calculate View multi entries (directory) based on a set of arguments ($args): |
||
915 | * $id - View id |
||
916 | * $page_size - Page |
||
917 | * $sort_field - form field id to sort |
||
918 | * $sort_direction - ASC / DESC |
||
919 | * $start_date - Ymd |
||
920 | * $end_date - Ymd |
||
921 | * $class - assign a html class to the view |
||
922 | * $offset (optional) - This is the start point in the current data set (0 index based). |
||
923 | * |
||
924 | * |
||
925 | * |
||
926 | * @uses gravityview_get_entries() |
||
927 | * @access public |
||
928 | * @param array $args\n |
||
929 | * - $id - View id |
||
930 | * - $page_size - Page |
||
931 | * - $sort_field - form field id to sort |
||
932 | * - $sort_direction - ASC / DESC |
||
933 | * - $start_date - Ymd |
||
934 | * - $end_date - Ymd |
||
935 | * - $class - assign a html class to the view |
||
936 | * - $offset (optional) - This is the start point in the current data set (0 index based). |
||
937 | * @param int $form_id Gravity Forms Form ID |
||
938 | * @return array Associative array with `count`, `entries`, and `paging` keys. `count` has the total entries count, `entries` is an array with Gravity Forms full entry data, `paging` is an array with `offset` and `page_size` keys |
||
939 | */ |
||
940 | 1 | public static function get_view_entries( $args, $form_id ) { |
|
977 | |||
978 | /** |
||
979 | * Get an array of search parameters formatted as Gravity Forms requires |
||
980 | * |
||
981 | * Results are filtered by `gravityview_get_entries` and `gravityview_get_entries_{View ID}` filters |
||
982 | * |
||
983 | * @uses GravityView_frontend::get_search_criteria |
||
984 | * @uses GravityView_frontend::get_search_criteria_paging |
||
985 | * |
||
986 | * @since 1.20 |
||
987 | * |
||
988 | * @see \GV\View_Settings::defaults For $args options |
||
989 | * |
||
990 | * @param array $args Array of View settings, as structured in \GV\View_Settings::defaults |
||
991 | * @param int $form_id Gravity Forms form ID to search |
||
992 | * |
||
993 | * @return array With `search_criteria`, `sorting`, `paging`, `cache` keys |
||
994 | */ |
||
995 | 76 | public static function get_view_entries_parameters( $args = array(), $form_id = 0 ) { |
|
1050 | |||
1051 | /** |
||
1052 | * Get the paging array for the View |
||
1053 | * |
||
1054 | * @since 1.19.5 |
||
1055 | * |
||
1056 | * @param $args |
||
1057 | * @param int $form_id |
||
1058 | */ |
||
1059 | 76 | public static function get_search_criteria_paging( $args ) { |
|
1060 | |||
1061 | /** |
||
1062 | * @filter `gravityview_default_page_size` The default number of entries displayed in a View |
||
1063 | * @since 1.1.6 |
||
1064 | * @param int $default_page_size Default: 25 |
||
1065 | */ |
||
1066 | 76 | $default_page_size = apply_filters( 'gravityview_default_page_size', 25 ); |
|
1067 | |||
1068 | // Paging & offset |
||
1069 | 76 | $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size; |
|
1070 | |||
1071 | 76 | if ( -1 === $page_size ) { |
|
1072 | 1 | $page_size = PHP_INT_MAX; |
|
1073 | } |
||
1074 | |||
1075 | 76 | $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
1076 | 76 | $offset = ( $curr_page - 1 ) * $page_size; |
|
1077 | |||
1078 | 76 | if ( ! empty( $args['offset'] ) ) { |
|
1079 | 1 | $offset += intval( $args['offset'] ); |
|
1080 | } |
||
1081 | |||
1082 | $paging = array( |
||
1083 | 76 | 'offset' => $offset, |
|
1084 | 76 | 'page_size' => $page_size, |
|
1085 | ); |
||
1086 | |||
1087 | 76 | gravityview()->log->debug( 'Paging: ', array( 'data' => $paging ) ); |
|
1088 | |||
1089 | 76 | return $paging; |
|
1090 | } |
||
1091 | |||
1092 | /** |
||
1093 | * Updates the View sorting criteria |
||
1094 | * |
||
1095 | * @since 1.7 |
||
1096 | * |
||
1097 | * @param array $args View settings. Required to have `sort_field` and `sort_direction` keys |
||
1098 | * @param int $form_id The ID of the form used to sort |
||
1099 | * @return array $sorting Array with `key`, `direction` and `is_numeric` keys |
||
1100 | */ |
||
1101 | 76 | public static function updateViewSorting( $args, $form_id ) { |
|
1180 | |||
1181 | /** |
||
1182 | * Override sorting per field |
||
1183 | * |
||
1184 | * Currently only modifies sorting ID when sorting by the full name. Sorts by first name. |
||
1185 | * Use the `gravityview/sorting/full-name` filter to override. |
||
1186 | * |
||
1187 | * @todo Filter from GravityView_Field |
||
1188 | * @since 1.7.4 |
||
1189 | * @internal Hi developer! Although this is public, don't call this method; we're going to replace it. |
||
1190 | * |
||
1191 | * @param int|string|array $sort_field_id Field used for sorting (`id` or `1.2`), or an array for multisorts |
||
1192 | * @param int $form_id GF Form ID |
||
1193 | * |
||
1194 | * @return string Possibly modified sorting ID |
||
1195 | */ |
||
1196 | 6 | public static function _override_sorting_id_by_field_type( $sort_field_id, $form_id ) { |
|
1197 | |||
1198 | 6 | if ( is_array( $sort_field_id ) ) { |
|
1199 | $modified_ids = array(); |
||
1200 | foreach ( $sort_field_id as $_sort_field_id ) { |
||
1201 | $modified_ids []= self::_override_sorting_id_by_field_type( $_sort_field_id, $form_id ); |
||
1202 | } |
||
1203 | return $modified_ids; |
||
1204 | } |
||
1205 | |||
1206 | 6 | $form = gravityview_get_form( $form_id ); |
|
1207 | |||
1208 | 6 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
|
1209 | |||
1210 | 6 | if( ! $sort_field ) { |
|
1211 | 1 | return $sort_field_id; |
|
1212 | } |
||
1213 | |||
1214 | 5 | switch ( $sort_field['type'] ) { |
|
1215 | |||
1216 | 5 | case 'address': |
|
1217 | // Sorting by full address |
||
1218 | if ( floatval( $sort_field_id ) === floor( $sort_field_id ) ) { |
||
1219 | |||
1220 | /** |
||
1221 | * Override how to sort when sorting address |
||
1222 | * |
||
1223 | * @since 1.8 |
||
1224 | * |
||
1225 | * @param string $address_part `street`, `street2`, `city`, `state`, `zip`, or `country` (default: `city`) |
||
1226 | * @param string $sort_field_id Field used for sorting |
||
1227 | * @param int $form_id GF Form ID |
||
1228 | */ |
||
1229 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
||
1230 | |||
1231 | switch( strtolower( $address_part ) ){ |
||
1232 | case 'street': |
||
1233 | $sort_field_id .= '.1'; |
||
1234 | break; |
||
1235 | case 'street2': |
||
1236 | $sort_field_id .= '.2'; |
||
1237 | break; |
||
1238 | default: |
||
1239 | case 'city': |
||
1240 | $sort_field_id .= '.3'; |
||
1241 | break; |
||
1242 | case 'state': |
||
1243 | $sort_field_id .= '.4'; |
||
1244 | break; |
||
1245 | case 'zip': |
||
1246 | $sort_field_id .= '.5'; |
||
1247 | break; |
||
1248 | case 'country': |
||
1249 | $sort_field_id .= '.6'; |
||
1250 | break; |
||
1251 | } |
||
1252 | |||
1253 | } |
||
1254 | break; |
||
1255 | 5 | case 'name': |
|
1256 | // Sorting by full name, not first, last, etc. |
||
1257 | if ( floatval( $sort_field_id ) === floor( $sort_field_id ) ) { |
||
1258 | /** |
||
1259 | * @filter `gravityview/sorting/full-name` Override how to sort when sorting full name. |
||
1260 | * @since 1.7.4 |
||
1261 | * @param[in,out] string $name_part Sort by `first` or `last` (default: `first`) |
||
1262 | * @param[in] string $sort_field_id Field used for sorting |
||
1263 | * @param[in] int $form_id GF Form ID |
||
1264 | */ |
||
1265 | $name_part = apply_filters( 'gravityview/sorting/full-name', 'first', $sort_field_id, $form_id ); |
||
1266 | |||
1267 | if ( 'last' === strtolower( $name_part ) ) { |
||
1268 | $sort_field_id .= '.6'; |
||
1269 | } else { |
||
1270 | $sort_field_id .= '.3'; |
||
1271 | } |
||
1272 | } |
||
1273 | break; |
||
1274 | 5 | case 'list': |
|
1275 | $sort_field_id = false; |
||
1276 | break; |
||
1277 | 5 | case 'time': |
|
1278 | |||
1279 | /** |
||
1280 | * @filter `gravityview/sorting/time` Override how to sort when sorting time |
||
1281 | * @see GravityView_Field_Time |
||
1282 | * @since 1.14 |
||
1283 | * @param[in,out] string $name_part Field used for sorting |
||
1284 | * @param[in] int $form_id GF Form ID |
||
1285 | */ |
||
1286 | 1 | $sort_field_id = apply_filters( 'gravityview/sorting/time', $sort_field_id, $form_id ); |
|
1287 | 1 | break; |
|
1288 | } |
||
1289 | |||
1290 | 5 | return $sort_field_id; |
|
1291 | } |
||
1292 | |||
1293 | /** |
||
1294 | * Verify if user requested a single entry view |
||
1295 | * @since 2.3.3 Added return null |
||
1296 | * @return boolean|string|null false if not, single entry slug if true, null if \GV\Entry doesn't exist yet |
||
1297 | */ |
||
1298 | 26 | public static function is_single_entry() { |
|
1327 | |||
1328 | |||
1329 | /** |
||
1330 | * Register styles and scripts |
||
1331 | * |
||
1332 | * @access public |
||
1333 | * @return void |
||
1334 | */ |
||
1335 | 1 | public function add_scripts_and_styles() { |
|
1453 | |||
1454 | /** |
||
1455 | * Handle enqueuing the `gravityview_default_style` stylesheet |
||
1456 | * |
||
1457 | * @since 1.17 |
||
1458 | * |
||
1459 | * @param array $css_dependencies Dependencies for the `gravityview_default_style` stylesheet |
||
1460 | * |
||
1461 | * @return void |
||
1462 | */ |
||
1463 | private function enqueue_default_style( $css_dependencies = array() ) { |
||
1480 | |||
1481 | /** |
||
1482 | * Add template extra style if exists |
||
1483 | * @param string $template_id |
||
1484 | */ |
||
1485 | public static function add_style( $template_id ) { |
||
1497 | |||
1498 | |||
1499 | /** |
||
1500 | * Inject the sorting links on the table columns |
||
1501 | * |
||
1502 | * Callback function for hook 'gravityview/template/field_label' |
||
1503 | * @see GravityView_API::field_label() (in includes/class-api.php) |
||
1504 | * |
||
1505 | * @since 1.7 |
||
1506 | * |
||
1507 | * @param string $label Field label |
||
1508 | * @param array $field Field settings |
||
1509 | * @param array $form Form object |
||
1510 | * |
||
1511 | * @return string Field Label |
||
1512 | */ |
||
1513 | public function add_columns_sort_links( $label = '', $field, $form ) { |
||
1556 | |||
1557 | /** |
||
1558 | * Checks if field (column) is sortable |
||
1559 | * |
||
1560 | * @param string $field Field settings |
||
1561 | * @param array $form Gravity Forms form array |
||
1562 | * |
||
1563 | * @since 1.7 |
||
1564 | * |
||
1565 | * @return bool True: Yes, field is sortable; False: not sortable |
||
1566 | */ |
||
1567 | 1 | public function is_field_sortable( $field_id = '', $form = array() ) { |
|
1597 | |||
1598 | } |
||
1599 | |||
1604 |