@@ -13,133 +13,133 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | class LSX_TEAM_SCPO_Engine { |
| 15 | 15 | |
| 16 | - public function __construct() { |
|
| 17 | - if ( ! get_option( 'lsx_team_scporder_install' ) ) |
|
| 18 | - $this->lsx_team_scporder_install(); |
|
| 16 | + public function __construct() { |
|
| 17 | + if ( ! get_option( 'lsx_team_scporder_install' ) ) |
|
| 18 | + $this->lsx_team_scporder_install(); |
|
| 19 | 19 | |
| 20 | - add_action( 'admin_init', array( $this, 'refresh' ) ); |
|
| 21 | - add_action( 'admin_init', array( $this, 'load_script_css' ) ); |
|
| 20 | + add_action( 'admin_init', array( $this, 'refresh' ) ); |
|
| 21 | + add_action( 'admin_init', array( $this, 'load_script_css' ) ); |
|
| 22 | 22 | |
| 23 | - add_action( 'wp_ajax_update-menu-order', array( $this, 'update_menu_order' ) ); |
|
| 24 | - add_action( 'wp_ajax_update-menu-order-tags', array( $this, 'update_menu_order_tags' ) ); |
|
| 23 | + add_action( 'wp_ajax_update-menu-order', array( $this, 'update_menu_order' ) ); |
|
| 24 | + add_action( 'wp_ajax_update-menu-order-tags', array( $this, 'update_menu_order_tags' ) ); |
|
| 25 | 25 | |
| 26 | - add_action( 'pre_get_posts', array( $this, 'lsx_team_scporder_pre_get_posts' ) ); |
|
| 26 | + add_action( 'pre_get_posts', array( $this, 'lsx_team_scporder_pre_get_posts' ) ); |
|
| 27 | 27 | |
| 28 | - add_filter( 'get_previous_post_where', array( $this, 'lsx_team_scporder_previous_post_where' ) ); |
|
| 29 | - add_filter( 'get_previous_post_sort', array( $this, 'lsx_team_scporder_previous_post_sort' ) ); |
|
| 30 | - add_filter( 'get_next_post_where', array( $this, 'lsx_team_scporder_next_post_where' ) ); |
|
| 31 | - add_filter( 'get_next_post_sort', array( $this, 'lsx_team_scporder_next_post_sort' ) ); |
|
| 28 | + add_filter( 'get_previous_post_where', array( $this, 'lsx_team_scporder_previous_post_where' ) ); |
|
| 29 | + add_filter( 'get_previous_post_sort', array( $this, 'lsx_team_scporder_previous_post_sort' ) ); |
|
| 30 | + add_filter( 'get_next_post_where', array( $this, 'lsx_team_scporder_next_post_where' ) ); |
|
| 31 | + add_filter( 'get_next_post_sort', array( $this, 'lsx_team_scporder_next_post_sort' ) ); |
|
| 32 | 32 | |
| 33 | - add_filter( 'get_terms_orderby', array( $this, 'lsx_team_scporder_get_terms_orderby' ), 10, 3 ); |
|
| 34 | - add_filter( 'wp_get_object_terms', array( $this, 'lsx_team_scporder_get_object_terms' ), 10, 3 ); |
|
| 35 | - add_filter( 'get_terms', array( $this, 'lsx_team_scporder_get_object_terms' ), 10, 3 ); |
|
| 36 | - } |
|
| 33 | + add_filter( 'get_terms_orderby', array( $this, 'lsx_team_scporder_get_terms_orderby' ), 10, 3 ); |
|
| 34 | + add_filter( 'wp_get_object_terms', array( $this, 'lsx_team_scporder_get_object_terms' ), 10, 3 ); |
|
| 35 | + add_filter( 'get_terms', array( $this, 'lsx_team_scporder_get_object_terms' ), 10, 3 ); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function lsx_team_scporder_install() { |
|
| 39 | - global $wpdb; |
|
| 40 | - $result = $wpdb->query( "DESCRIBE $wpdb->terms `lsx_team_term_order`" ); |
|
| 38 | + public function lsx_team_scporder_install() { |
|
| 39 | + global $wpdb; |
|
| 40 | + $result = $wpdb->query( "DESCRIBE $wpdb->terms `lsx_team_term_order`" ); |
|
| 41 | 41 | |
| 42 | - if ( ! $result ) { |
|
| 43 | - $result = $wpdb->query( "ALTER TABLE $wpdb->terms ADD `lsx_team_term_order` INT( 4 ) NULL DEFAULT '0'" ); |
|
| 44 | - } |
|
| 42 | + if ( ! $result ) { |
|
| 43 | + $result = $wpdb->query( "ALTER TABLE $wpdb->terms ADD `lsx_team_term_order` INT( 4 ) NULL DEFAULT '0'" ); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - update_option( 'lsx_team_scporder_install', 1 ); |
|
| 47 | - } |
|
| 46 | + update_option( 'lsx_team_scporder_install', 1 ); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function _check_load_script_css() { |
|
| 50 | - $active = false; |
|
| 49 | + public function _check_load_script_css() { |
|
| 50 | + $active = false; |
|
| 51 | 51 | |
| 52 | - $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 53 | - $tags = $this->get_lsx_team_scporder_options_tags(); |
|
| 52 | + $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 53 | + $tags = $this->get_lsx_team_scporder_options_tags(); |
|
| 54 | 54 | |
| 55 | - if ( empty( $objects ) && empty( $tags ) ) |
|
| 56 | - return false; |
|
| 55 | + if ( empty( $objects ) && empty( $tags ) ) |
|
| 56 | + return false; |
|
| 57 | 57 | |
| 58 | - if ( isset( $_GET['orderby'] ) || strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'action=edit' ) || strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'wp-admin/post-new.php' ) ) |
|
| 59 | - return false; |
|
| 58 | + if ( isset( $_GET['orderby'] ) || strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'action=edit' ) || strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'wp-admin/post-new.php' ) ) |
|
| 59 | + return false; |
|
| 60 | 60 | |
| 61 | - if ( ! empty( $objects ) ) { |
|
| 62 | - if ( isset( $_GET['post_type'] ) && ! isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( wp_unslash( $_GET['post_type'] ) ), $objects ) ) { // if page or custom post types. |
|
| 63 | - $active = true; |
|
| 64 | - } |
|
| 65 | - if ( ! isset( $_GET['post_type'] ) && strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'wp-admin/edit.php' ) && array_key_exists( 'post', $objects ) ) { // if post. |
|
| 66 | - $active = true; |
|
| 67 | - } |
|
| 68 | - } |
|
| 61 | + if ( ! empty( $objects ) ) { |
|
| 62 | + if ( isset( $_GET['post_type'] ) && ! isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( wp_unslash( $_GET['post_type'] ) ), $objects ) ) { // if page or custom post types. |
|
| 63 | + $active = true; |
|
| 64 | + } |
|
| 65 | + if ( ! isset( $_GET['post_type'] ) && strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'wp-admin/edit.php' ) && array_key_exists( 'post', $objects ) ) { // if post. |
|
| 66 | + $active = true; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - if ( ! empty( $tags ) ) { |
|
| 71 | - if ( isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) ), $tags ) ) { |
|
| 72 | - $active = true; |
|
| 73 | - } |
|
| 74 | - } |
|
| 70 | + if ( ! empty( $tags ) ) { |
|
| 71 | + if ( isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) ), $tags ) ) { |
|
| 72 | + $active = true; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return $active; |
|
| 77 | - } |
|
| 76 | + return $active; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - public function load_script_css() { |
|
| 80 | - if ( $this->_check_load_script_css() ) { |
|
| 81 | - wp_enqueue_script( 'scporderjs', LSX_TEAM_URL . 'assets/js/scporder.min.js', array( 'jquery', 'jquery-ui-sortable' ), null, true ); |
|
| 79 | + public function load_script_css() { |
|
| 80 | + if ( $this->_check_load_script_css() ) { |
|
| 81 | + wp_enqueue_script( 'scporderjs', LSX_TEAM_URL . 'assets/js/scporder.min.js', array( 'jquery', 'jquery-ui-sortable' ), null, true ); |
|
| 82 | 82 | |
| 83 | - $scporderjs_params = array( |
|
| 84 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 85 | - 'ajax_nonce' => wp_create_nonce( 'scporder' ), |
|
| 86 | - ); |
|
| 83 | + $scporderjs_params = array( |
|
| 84 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 85 | + 'ajax_nonce' => wp_create_nonce( 'scporder' ), |
|
| 86 | + ); |
|
| 87 | 87 | |
| 88 | - wp_localize_script( 'scporderjs', 'scporderjs_params', $scporderjs_params ); |
|
| 88 | + wp_localize_script( 'scporderjs', 'scporderjs_params', $scporderjs_params ); |
|
| 89 | 89 | |
| 90 | - wp_enqueue_style( 'scporder', LSX_TEAM_URL . 'assets/css/scporder.css', array(), null ); |
|
| 91 | - } |
|
| 92 | - } |
|
| 90 | + wp_enqueue_style( 'scporder', LSX_TEAM_URL . 'assets/css/scporder.css', array(), null ); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - public function refresh() { |
|
| 95 | - global $wpdb; |
|
| 96 | - $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 97 | - $tags = $this->get_lsx_team_scporder_options_tags(); |
|
| 94 | + public function refresh() { |
|
| 95 | + global $wpdb; |
|
| 96 | + $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 97 | + $tags = $this->get_lsx_team_scporder_options_tags(); |
|
| 98 | 98 | |
| 99 | - if ( ! empty( $objects ) ) { |
|
| 100 | - foreach ( $objects as $object => $object_data ) { |
|
| 101 | - $result = $wpdb->get_results( $wpdb->prepare( " |
|
| 99 | + if ( ! empty( $objects ) ) { |
|
| 100 | + foreach ( $objects as $object => $object_data ) { |
|
| 101 | + $result = $wpdb->get_results( $wpdb->prepare( " |
|
| 102 | 102 | SELECT count( * ) as cnt, max( menu_order ) as max, min( menu_order ) as min |
| 103 | 103 | FROM $wpdb->posts |
| 104 | 104 | WHERE post_type = '%s' AND post_status IN ( 'publish', 'pending', 'draft', 'private', 'future' ) |
| 105 | 105 | ", $object ) ); |
| 106 | 106 | |
| 107 | - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) |
|
| 108 | - continue; |
|
| 107 | + if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) |
|
| 108 | + continue; |
|
| 109 | 109 | |
| 110 | - $results = $wpdb->get_results( $wpdb->prepare( " |
|
| 110 | + $results = $wpdb->get_results( $wpdb->prepare( " |
|
| 111 | 111 | SELECT ID |
| 112 | 112 | FROM $wpdb->posts |
| 113 | 113 | WHERE post_type = '%s' AND post_status IN ( 'publish', 'pending', 'draft', 'private', 'future' ) |
| 114 | 114 | ORDER BY menu_order ASC |
| 115 | 115 | ", $object ) ); |
| 116 | 116 | |
| 117 | - foreach ( $results as $key => $result ) { |
|
| 118 | - $wpdb->update( $wpdb->posts, |
|
| 119 | - array( |
|
| 120 | - 'menu_order' => $key + 1, |
|
| 121 | - ), |
|
| 122 | - array( |
|
| 123 | - 'ID' => $result->ID, |
|
| 124 | - ) |
|
| 125 | - ); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - if ( ! empty( $tags ) ) { |
|
| 131 | - foreach ( $tags as $taxonomy => $taxonomy_data ) { |
|
| 132 | - $result = $wpdb->get_results( $wpdb->prepare( " |
|
| 117 | + foreach ( $results as $key => $result ) { |
|
| 118 | + $wpdb->update( $wpdb->posts, |
|
| 119 | + array( |
|
| 120 | + 'menu_order' => $key + 1, |
|
| 121 | + ), |
|
| 122 | + array( |
|
| 123 | + 'ID' => $result->ID, |
|
| 124 | + ) |
|
| 125 | + ); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + if ( ! empty( $tags ) ) { |
|
| 131 | + foreach ( $tags as $taxonomy => $taxonomy_data ) { |
|
| 132 | + $result = $wpdb->get_results( $wpdb->prepare( " |
|
| 133 | 133 | SELECT count( * ) as cnt, max( lsx_team_term_order ) as max, min( lsx_team_term_order ) as min |
| 134 | 134 | FROM $wpdb->terms AS terms |
| 135 | 135 | INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) |
| 136 | 136 | WHERE term_taxonomy.taxonomy = '%s' |
| 137 | 137 | ", $taxonomy ) ); |
| 138 | 138 | |
| 139 | - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) |
|
| 140 | - continue; |
|
| 139 | + if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) |
|
| 140 | + continue; |
|
| 141 | 141 | |
| 142 | - $results = $wpdb->get_results( $wpdb->prepare( " |
|
| 142 | + $results = $wpdb->get_results( $wpdb->prepare( " |
|
| 143 | 143 | SELECT terms.term_id |
| 144 | 144 | FROM $wpdb->terms AS terms |
| 145 | 145 | INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) |
@@ -147,270 +147,270 @@ discard block |
||
| 147 | 147 | ORDER BY lsx_team_term_order ASC |
| 148 | 148 | ", $taxonomy ) ); |
| 149 | 149 | |
| 150 | - foreach ( $results as $key => $result ) { |
|
| 151 | - $wpdb->update( |
|
| 152 | - $wpdb->terms, |
|
| 153 | - array( |
|
| 154 | - 'lsx_team_term_order' => $key + 1, |
|
| 155 | - ), |
|
| 156 | - array( |
|
| 157 | - 'term_id' => $result->term_id, |
|
| 158 | - ) |
|
| 159 | - ); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - public function update_menu_order() { |
|
| 166 | - check_ajax_referer( 'scporder', 'security' ); |
|
| 167 | - |
|
| 168 | - global $wpdb; |
|
| 169 | - |
|
| 170 | - parse_str( sanitize_text_field( wp_unslash( $_POST['order'] ) ), $data ); |
|
| 171 | - |
|
| 172 | - if ( ! is_array( $data ) ) |
|
| 173 | - return false; |
|
| 174 | - |
|
| 175 | - $id_arr = array(); |
|
| 176 | - |
|
| 177 | - foreach ( $data as $key => $values ) { |
|
| 178 | - foreach ( $values as $position => $id ) { |
|
| 179 | - $id_arr[] = $id; |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - $menu_order_arr = array(); |
|
| 184 | - |
|
| 185 | - foreach ( $id_arr as $key => $id ) { |
|
| 186 | - $results = $wpdb->get_results( "SELECT menu_order FROM $wpdb->posts WHERE ID = " . intval( $id ) ); |
|
| 187 | - foreach ( $results as $result ) { |
|
| 188 | - $menu_order_arr[] = $result->menu_order; |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - sort( $menu_order_arr ); |
|
| 193 | - |
|
| 194 | - foreach ( $data as $key => $values ) { |
|
| 195 | - foreach ( $values as $position => $id ) { |
|
| 196 | - $wpdb->update( $wpdb->posts, |
|
| 197 | - array( |
|
| 198 | - 'menu_order' => $menu_order_arr[ $position ], |
|
| 199 | - ), |
|
| 200 | - array( |
|
| 201 | - 'ID' => intval( $id ), |
|
| 202 | - ) |
|
| 203 | - ); |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - public function update_menu_order_tags() { |
|
| 209 | - check_ajax_referer( 'scporder', 'security' ); |
|
| 210 | - |
|
| 211 | - global $wpdb; |
|
| 212 | - |
|
| 213 | - parse_str( sanitize_text_field( wp_unslash( $_POST['order'] ) ), $data ); |
|
| 214 | - |
|
| 215 | - if ( ! is_array( $data ) ) |
|
| 216 | - return false; |
|
| 217 | - |
|
| 218 | - $id_arr = array(); |
|
| 219 | - |
|
| 220 | - foreach ( $data as $key => $values ) { |
|
| 221 | - foreach ( $values as $position => $id ) { |
|
| 222 | - $id_arr[] = $id; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - $menu_order_arr = array(); |
|
| 227 | - |
|
| 228 | - foreach ( $id_arr as $key => $id ) { |
|
| 229 | - $results = $wpdb->get_results( " |
|
| 150 | + foreach ( $results as $key => $result ) { |
|
| 151 | + $wpdb->update( |
|
| 152 | + $wpdb->terms, |
|
| 153 | + array( |
|
| 154 | + 'lsx_team_term_order' => $key + 1, |
|
| 155 | + ), |
|
| 156 | + array( |
|
| 157 | + 'term_id' => $result->term_id, |
|
| 158 | + ) |
|
| 159 | + ); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + public function update_menu_order() { |
|
| 166 | + check_ajax_referer( 'scporder', 'security' ); |
|
| 167 | + |
|
| 168 | + global $wpdb; |
|
| 169 | + |
|
| 170 | + parse_str( sanitize_text_field( wp_unslash( $_POST['order'] ) ), $data ); |
|
| 171 | + |
|
| 172 | + if ( ! is_array( $data ) ) |
|
| 173 | + return false; |
|
| 174 | + |
|
| 175 | + $id_arr = array(); |
|
| 176 | + |
|
| 177 | + foreach ( $data as $key => $values ) { |
|
| 178 | + foreach ( $values as $position => $id ) { |
|
| 179 | + $id_arr[] = $id; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + $menu_order_arr = array(); |
|
| 184 | + |
|
| 185 | + foreach ( $id_arr as $key => $id ) { |
|
| 186 | + $results = $wpdb->get_results( "SELECT menu_order FROM $wpdb->posts WHERE ID = " . intval( $id ) ); |
|
| 187 | + foreach ( $results as $result ) { |
|
| 188 | + $menu_order_arr[] = $result->menu_order; |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + sort( $menu_order_arr ); |
|
| 193 | + |
|
| 194 | + foreach ( $data as $key => $values ) { |
|
| 195 | + foreach ( $values as $position => $id ) { |
|
| 196 | + $wpdb->update( $wpdb->posts, |
|
| 197 | + array( |
|
| 198 | + 'menu_order' => $menu_order_arr[ $position ], |
|
| 199 | + ), |
|
| 200 | + array( |
|
| 201 | + 'ID' => intval( $id ), |
|
| 202 | + ) |
|
| 203 | + ); |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + public function update_menu_order_tags() { |
|
| 209 | + check_ajax_referer( 'scporder', 'security' ); |
|
| 210 | + |
|
| 211 | + global $wpdb; |
|
| 212 | + |
|
| 213 | + parse_str( sanitize_text_field( wp_unslash( $_POST['order'] ) ), $data ); |
|
| 214 | + |
|
| 215 | + if ( ! is_array( $data ) ) |
|
| 216 | + return false; |
|
| 217 | + |
|
| 218 | + $id_arr = array(); |
|
| 219 | + |
|
| 220 | + foreach ( $data as $key => $values ) { |
|
| 221 | + foreach ( $values as $position => $id ) { |
|
| 222 | + $id_arr[] = $id; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + $menu_order_arr = array(); |
|
| 227 | + |
|
| 228 | + foreach ( $id_arr as $key => $id ) { |
|
| 229 | + $results = $wpdb->get_results( " |
|
| 230 | 230 | SELECT lsx_team_term_order |
| 231 | 231 | FROM $wpdb->terms |
| 232 | 232 | WHERE term_id = " . intval( $id ) ); |
| 233 | - foreach ( $results as $result ) { |
|
| 234 | - $menu_order_arr[] = $result->lsx_team_term_order; |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - sort( $menu_order_arr ); |
|
| 239 | - |
|
| 240 | - foreach ( $data as $key => $values ) { |
|
| 241 | - foreach ( $values as $position => $id ) { |
|
| 242 | - $wpdb->update( $wpdb->terms, |
|
| 243 | - array( |
|
| 244 | - 'lsx_team_term_order' => $menu_order_arr[ $position ], |
|
| 245 | - ), |
|
| 246 | - array( |
|
| 247 | - 'term_id' => intval( $id ), |
|
| 248 | - ) |
|
| 249 | - ); |
|
| 250 | - } |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - public function lsx_team_scporder_previous_post_where( $where ) { |
|
| 255 | - global $post; |
|
| 256 | - $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 257 | - |
|
| 258 | - if ( empty( $objects ) ) |
|
| 259 | - return $where; |
|
| 260 | - |
|
| 261 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
| 262 | - $current_menu_order = $post->menu_order; |
|
| 263 | - $where = "WHERE p.menu_order > '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - return $where; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - public function lsx_team_scporder_previous_post_sort( $orderby ) { |
|
| 270 | - global $post; |
|
| 271 | - $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 272 | - |
|
| 273 | - if ( empty( $objects ) ) |
|
| 274 | - return $orderby; |
|
| 275 | - |
|
| 276 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
| 277 | - $orderby = 'ORDER BY p.menu_order ASC LIMIT 1'; |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - return $orderby; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - public function lsx_team_scporder_next_post_where( $where ) { |
|
| 284 | - global $post; |
|
| 285 | - $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 286 | - |
|
| 287 | - if ( empty( $objects ) ) |
|
| 288 | - return $where; |
|
| 289 | - |
|
| 290 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
| 291 | - $current_menu_order = $post->menu_order; |
|
| 292 | - $where = "WHERE p.menu_order < '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - return $where; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - public function lsx_team_scporder_next_post_sort( $orderby ) { |
|
| 299 | - global $post; |
|
| 300 | - $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 301 | - |
|
| 302 | - if ( empty( $objects ) ) |
|
| 303 | - return $orderby; |
|
| 304 | - |
|
| 305 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
| 306 | - $orderby = 'ORDER BY p.menu_order DESC LIMIT 1'; |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - return $orderby; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - public function lsx_team_scporder_pre_get_posts( $wp_query ) { |
|
| 313 | - $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 314 | - |
|
| 315 | - if ( empty( $objects ) ) |
|
| 316 | - return false; |
|
| 317 | - |
|
| 318 | - if ( is_admin() ) { |
|
| 319 | - if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) { |
|
| 320 | - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
| 321 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
| 322 | - $wp_query->set( 'order', 'ASC' ); |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - } else { |
|
| 326 | - $active = false; |
|
| 327 | - |
|
| 328 | - if ( isset( $wp_query->query['post_type'] ) ) { |
|
| 329 | - if ( ! is_array( $wp_query->query['post_type'] ) ) { |
|
| 330 | - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
| 331 | - $active = true; |
|
| 332 | - } |
|
| 333 | - } |
|
| 334 | - } else { |
|
| 335 | - if ( array_key_exists( 'post', $objects ) ) { |
|
| 336 | - $active = true; |
|
| 337 | - } |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - if ( ! $active ) |
|
| 341 | - return false; |
|
| 342 | - |
|
| 343 | - if ( isset( $wp_query->query['suppress_filters'] ) ) { |
|
| 344 | - if ( $wp_query->get( 'orderby' ) == 'date' ) |
|
| 345 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
| 346 | - if ( $wp_query->get( 'order' ) == 'DESC' ) |
|
| 347 | - $wp_query->set( 'order', 'ASC' ); |
|
| 348 | - } else { |
|
| 349 | - if ( ! $wp_query->get( 'orderby' ) ) |
|
| 350 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
| 351 | - if ( ! $wp_query->get( 'order' ) ) |
|
| 352 | - $wp_query->set( 'order', 'ASC' ); |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - public function lsx_team_scporder_get_terms_orderby( $orderby, $args ) { |
|
| 358 | - if ( is_admin() ) |
|
| 359 | - return $orderby; |
|
| 360 | - |
|
| 361 | - $tags = $this->get_lsx_team_scporder_options_tags(); |
|
| 362 | - |
|
| 363 | - if ( ! isset( $args['taxonomy'] ) ) |
|
| 364 | - return $orderby; |
|
| 365 | - |
|
| 366 | - $taxonomy = $args['taxonomy']; |
|
| 367 | - if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 ) |
|
| 368 | - $taxonomy = $taxonomy[0]; |
|
| 369 | - if ( ! array_key_exists( $taxonomy[0], $tags ) ) |
|
| 370 | - return $orderby; |
|
| 371 | - |
|
| 372 | - $orderby = 't.lsx_team_term_order'; |
|
| 373 | - return $orderby; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - public function lsx_team_scporder_get_object_terms( $terms ) { |
|
| 377 | - $tags = $this->get_lsx_team_scporder_options_tags(); |
|
| 378 | - |
|
| 379 | - if ( is_admin() && isset( $_GET['orderby'] ) ) |
|
| 380 | - return $terms; |
|
| 381 | - |
|
| 382 | - foreach ( $terms as $key => $term ) { |
|
| 383 | - if ( is_object( $term ) && isset( $term->taxonomy ) ) { |
|
| 384 | - $taxonomy = $term->taxonomy; |
|
| 385 | - if ( ! array_key_exists( $taxonomy, $tags ) ) |
|
| 386 | - return $terms; |
|
| 387 | - } else { |
|
| 388 | - return $terms; |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - usort( $terms, array( $this, 'taxcmp' ) ); |
|
| 393 | - return $terms; |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - public function taxcmp( $a, $b ) { |
|
| 397 | - if ( $a->lsx_team_term_order == $b->lsx_team_term_order ) |
|
| 398 | - return 0; |
|
| 399 | - |
|
| 400 | - return ( $a->lsx_team_term_order < $b->lsx_team_term_order ) ? -1 : 1; |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - public function get_lsx_team_scporder_options_objects() { |
|
| 404 | - return array( |
|
| 405 | - 'team' => esc_html_x( 'Team Member', 'post type singular name', 'lsx-team' ), |
|
| 406 | - ); |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - public function get_lsx_team_scporder_options_tags() { |
|
| 410 | - return array( |
|
| 411 | - 'team_role' => esc_html_x( 'Role', 'taxonomy singular name', 'lsx-team' ), |
|
| 412 | - ); |
|
| 413 | - } |
|
| 233 | + foreach ( $results as $result ) { |
|
| 234 | + $menu_order_arr[] = $result->lsx_team_term_order; |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + sort( $menu_order_arr ); |
|
| 239 | + |
|
| 240 | + foreach ( $data as $key => $values ) { |
|
| 241 | + foreach ( $values as $position => $id ) { |
|
| 242 | + $wpdb->update( $wpdb->terms, |
|
| 243 | + array( |
|
| 244 | + 'lsx_team_term_order' => $menu_order_arr[ $position ], |
|
| 245 | + ), |
|
| 246 | + array( |
|
| 247 | + 'term_id' => intval( $id ), |
|
| 248 | + ) |
|
| 249 | + ); |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + public function lsx_team_scporder_previous_post_where( $where ) { |
|
| 255 | + global $post; |
|
| 256 | + $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 257 | + |
|
| 258 | + if ( empty( $objects ) ) |
|
| 259 | + return $where; |
|
| 260 | + |
|
| 261 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
| 262 | + $current_menu_order = $post->menu_order; |
|
| 263 | + $where = "WHERE p.menu_order > '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + return $where; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + public function lsx_team_scporder_previous_post_sort( $orderby ) { |
|
| 270 | + global $post; |
|
| 271 | + $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 272 | + |
|
| 273 | + if ( empty( $objects ) ) |
|
| 274 | + return $orderby; |
|
| 275 | + |
|
| 276 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
| 277 | + $orderby = 'ORDER BY p.menu_order ASC LIMIT 1'; |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + return $orderby; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + public function lsx_team_scporder_next_post_where( $where ) { |
|
| 284 | + global $post; |
|
| 285 | + $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 286 | + |
|
| 287 | + if ( empty( $objects ) ) |
|
| 288 | + return $where; |
|
| 289 | + |
|
| 290 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
| 291 | + $current_menu_order = $post->menu_order; |
|
| 292 | + $where = "WHERE p.menu_order < '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + return $where; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + public function lsx_team_scporder_next_post_sort( $orderby ) { |
|
| 299 | + global $post; |
|
| 300 | + $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 301 | + |
|
| 302 | + if ( empty( $objects ) ) |
|
| 303 | + return $orderby; |
|
| 304 | + |
|
| 305 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
| 306 | + $orderby = 'ORDER BY p.menu_order DESC LIMIT 1'; |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + return $orderby; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + public function lsx_team_scporder_pre_get_posts( $wp_query ) { |
|
| 313 | + $objects = $this->get_lsx_team_scporder_options_objects(); |
|
| 314 | + |
|
| 315 | + if ( empty( $objects ) ) |
|
| 316 | + return false; |
|
| 317 | + |
|
| 318 | + if ( is_admin() ) { |
|
| 319 | + if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) { |
|
| 320 | + if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
| 321 | + $wp_query->set( 'orderby', 'menu_order' ); |
|
| 322 | + $wp_query->set( 'order', 'ASC' ); |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + } else { |
|
| 326 | + $active = false; |
|
| 327 | + |
|
| 328 | + if ( isset( $wp_query->query['post_type'] ) ) { |
|
| 329 | + if ( ! is_array( $wp_query->query['post_type'] ) ) { |
|
| 330 | + if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
| 331 | + $active = true; |
|
| 332 | + } |
|
| 333 | + } |
|
| 334 | + } else { |
|
| 335 | + if ( array_key_exists( 'post', $objects ) ) { |
|
| 336 | + $active = true; |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + if ( ! $active ) |
|
| 341 | + return false; |
|
| 342 | + |
|
| 343 | + if ( isset( $wp_query->query['suppress_filters'] ) ) { |
|
| 344 | + if ( $wp_query->get( 'orderby' ) == 'date' ) |
|
| 345 | + $wp_query->set( 'orderby', 'menu_order' ); |
|
| 346 | + if ( $wp_query->get( 'order' ) == 'DESC' ) |
|
| 347 | + $wp_query->set( 'order', 'ASC' ); |
|
| 348 | + } else { |
|
| 349 | + if ( ! $wp_query->get( 'orderby' ) ) |
|
| 350 | + $wp_query->set( 'orderby', 'menu_order' ); |
|
| 351 | + if ( ! $wp_query->get( 'order' ) ) |
|
| 352 | + $wp_query->set( 'order', 'ASC' ); |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + public function lsx_team_scporder_get_terms_orderby( $orderby, $args ) { |
|
| 358 | + if ( is_admin() ) |
|
| 359 | + return $orderby; |
|
| 360 | + |
|
| 361 | + $tags = $this->get_lsx_team_scporder_options_tags(); |
|
| 362 | + |
|
| 363 | + if ( ! isset( $args['taxonomy'] ) ) |
|
| 364 | + return $orderby; |
|
| 365 | + |
|
| 366 | + $taxonomy = $args['taxonomy']; |
|
| 367 | + if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 ) |
|
| 368 | + $taxonomy = $taxonomy[0]; |
|
| 369 | + if ( ! array_key_exists( $taxonomy[0], $tags ) ) |
|
| 370 | + return $orderby; |
|
| 371 | + |
|
| 372 | + $orderby = 't.lsx_team_term_order'; |
|
| 373 | + return $orderby; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + public function lsx_team_scporder_get_object_terms( $terms ) { |
|
| 377 | + $tags = $this->get_lsx_team_scporder_options_tags(); |
|
| 378 | + |
|
| 379 | + if ( is_admin() && isset( $_GET['orderby'] ) ) |
|
| 380 | + return $terms; |
|
| 381 | + |
|
| 382 | + foreach ( $terms as $key => $term ) { |
|
| 383 | + if ( is_object( $term ) && isset( $term->taxonomy ) ) { |
|
| 384 | + $taxonomy = $term->taxonomy; |
|
| 385 | + if ( ! array_key_exists( $taxonomy, $tags ) ) |
|
| 386 | + return $terms; |
|
| 387 | + } else { |
|
| 388 | + return $terms; |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + usort( $terms, array( $this, 'taxcmp' ) ); |
|
| 393 | + return $terms; |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + public function taxcmp( $a, $b ) { |
|
| 397 | + if ( $a->lsx_team_term_order == $b->lsx_team_term_order ) |
|
| 398 | + return 0; |
|
| 399 | + |
|
| 400 | + return ( $a->lsx_team_term_order < $b->lsx_team_term_order ) ? -1 : 1; |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + public function get_lsx_team_scporder_options_objects() { |
|
| 404 | + return array( |
|
| 405 | + 'team' => esc_html_x( 'Team Member', 'post type singular name', 'lsx-team' ), |
|
| 406 | + ); |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + public function get_lsx_team_scporder_options_tags() { |
|
| 410 | + return array( |
|
| 411 | + 'team_role' => esc_html_x( 'Role', 'taxonomy singular name', 'lsx-team' ), |
|
| 412 | + ); |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | 415 | } |
| 416 | 416 | |
@@ -420,30 +420,30 @@ discard block |
||
| 420 | 420 | register_uninstall_hook( __FILE__, 'lsx_team_scporder_uninstall' ); |
| 421 | 421 | |
| 422 | 422 | function lsx_team_scporder_uninstall() { |
| 423 | - global $wpdb; |
|
| 423 | + global $wpdb; |
|
| 424 | 424 | |
| 425 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
| 426 | - $curr_blog = $wpdb->blogid; |
|
| 427 | - $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
| 425 | + if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
| 426 | + $curr_blog = $wpdb->blogid; |
|
| 427 | + $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
| 428 | 428 | |
| 429 | - foreach ( $blogids as $blog_id ) { |
|
| 430 | - switch_to_blog( $blog_id ); |
|
| 431 | - lsx_team_scporder_uninstall_db(); |
|
| 432 | - } |
|
| 429 | + foreach ( $blogids as $blog_id ) { |
|
| 430 | + switch_to_blog( $blog_id ); |
|
| 431 | + lsx_team_scporder_uninstall_db(); |
|
| 432 | + } |
|
| 433 | 433 | |
| 434 | - switch_to_blog( $curr_blog ); |
|
| 435 | - } else { |
|
| 436 | - lsx_team_scporder_uninstall_db(); |
|
| 437 | - } |
|
| 434 | + switch_to_blog( $curr_blog ); |
|
| 435 | + } else { |
|
| 436 | + lsx_team_scporder_uninstall_db(); |
|
| 437 | + } |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | function lsx_team_scporder_uninstall_db() { |
| 441 | - global $wpdb; |
|
| 442 | - $result = $wpdb->query( "DESCRIBE $wpdb->terms `lsx_team_term_order`" ); |
|
| 441 | + global $wpdb; |
|
| 442 | + $result = $wpdb->query( "DESCRIBE $wpdb->terms `lsx_team_term_order`" ); |
|
| 443 | 443 | |
| 444 | - if ( $result ) { |
|
| 445 | - $result = $wpdb->query( "ALTER TABLE $wpdb->terms DROP `lsx_team_term_order`" ); |
|
| 446 | - } |
|
| 444 | + if ( $result ) { |
|
| 445 | + $result = $wpdb->query( "ALTER TABLE $wpdb->terms DROP `lsx_team_term_order`" ); |
|
| 446 | + } |
|
| 447 | 447 | |
| 448 | - delete_option( 'lsx_team_scporder_install' ); |
|
| 448 | + delete_option( 'lsx_team_scporder_install' ); |
|
| 449 | 449 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * Add our action to init to set up our vars first. |
| 14 | 14 | */ |
| 15 | 15 | function lsx_team_load_plugin_textdomain() { |
| 16 | - load_plugin_textdomain( 'lsx-team', false, basename( LSX_TEAM_PATH ) . '/languages' ); |
|
| 16 | + load_plugin_textdomain( 'lsx-team', false, basename( LSX_TEAM_PATH ) . '/languages' ); |
|
| 17 | 17 | } |
| 18 | 18 | add_action( 'init', 'lsx_team_load_plugin_textdomain' ); |
| 19 | 19 | |
@@ -25,23 +25,23 @@ discard block |
||
| 25 | 25 | * @return mixed Option value |
| 26 | 26 | */ |
| 27 | 27 | function team_get_options() { |
| 28 | - $options = array(); |
|
| 29 | - if ( function_exists( 'tour_operator' ) ) { |
|
| 30 | - $options = get_option( '_lsx-to_settings', false ); |
|
| 31 | - } else { |
|
| 32 | - $options = get_option( '_lsx_settings', false ); |
|
| 33 | - |
|
| 34 | - if ( false === $options ) { |
|
| 35 | - $options = get_option( '_lsx_lsx-settings', false ); |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - // If there are new CMB2 options available, then use those. |
|
| 40 | - $new_options = get_option( 'lsx_team_options', false ); |
|
| 41 | - if ( false !== $new_options ) { |
|
| 42 | - $options['display'] = $new_options; |
|
| 43 | - } |
|
| 44 | - return $options; |
|
| 28 | + $options = array(); |
|
| 29 | + if ( function_exists( 'tour_operator' ) ) { |
|
| 30 | + $options = get_option( '_lsx-to_settings', false ); |
|
| 31 | + } else { |
|
| 32 | + $options = get_option( '_lsx_settings', false ); |
|
| 33 | + |
|
| 34 | + if ( false === $options ) { |
|
| 35 | + $options = get_option( '_lsx_lsx-settings', false ); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + // If there are new CMB2 options available, then use those. |
|
| 40 | + $new_options = get_option( 'lsx_team_options', false ); |
|
| 41 | + if ( false !== $new_options ) { |
|
| 42 | + $options['display'] = $new_options; |
|
| 43 | + } |
|
| 44 | + return $options; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -52,44 +52,44 @@ discard block |
||
| 52 | 52 | * @return mixed Option value |
| 53 | 53 | */ |
| 54 | 54 | function team_get_option( $key = '', $default = false ) { |
| 55 | - $options = array(); |
|
| 56 | - $value = $default; |
|
| 57 | - if ( function_exists( 'tour_operator' ) ) { |
|
| 58 | - $options = get_option( '_lsx-to_settings', false ); |
|
| 59 | - } else { |
|
| 60 | - $options = get_option( '_lsx_settings', false ); |
|
| 61 | - |
|
| 62 | - if ( false === $options ) { |
|
| 63 | - $options = get_option( '_lsx_lsx-settings', false ); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - // If there are new CMB2 options available, then use those. |
|
| 68 | - $new_options = get_option( 'lsx_team_options', false ); |
|
| 69 | - if ( false !== $new_options ) { |
|
| 70 | - $options['display'] = $new_options; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - if ( isset( $options['display'] ) && isset( $options['display'][ $key ] ) ) { |
|
| 74 | - $value = $options['display'][ $key ]; |
|
| 75 | - } |
|
| 76 | - return $value; |
|
| 55 | + $options = array(); |
|
| 56 | + $value = $default; |
|
| 57 | + if ( function_exists( 'tour_operator' ) ) { |
|
| 58 | + $options = get_option( '_lsx-to_settings', false ); |
|
| 59 | + } else { |
|
| 60 | + $options = get_option( '_lsx_settings', false ); |
|
| 61 | + |
|
| 62 | + if ( false === $options ) { |
|
| 63 | + $options = get_option( '_lsx_lsx-settings', false ); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // If there are new CMB2 options available, then use those. |
|
| 68 | + $new_options = get_option( 'lsx_team_options', false ); |
|
| 69 | + if ( false !== $new_options ) { |
|
| 70 | + $options['display'] = $new_options; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + if ( isset( $options['display'] ) && isset( $options['display'][ $key ] ) ) { |
|
| 74 | + $value = $options['display'][ $key ]; |
|
| 75 | + } |
|
| 76 | + return $value; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Wraps the output class in a function to be called in templates |
| 81 | 81 | */ |
| 82 | 82 | function lsx_team( $args ) { |
| 83 | - $lsx_team = new LSX_Team; |
|
| 84 | - echo wp_kses_post( $lsx_team->output( $args ) ); |
|
| 83 | + $lsx_team = new LSX_Team; |
|
| 84 | + echo wp_kses_post( $lsx_team->output( $args ) ); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * Shortcode |
| 89 | 89 | */ |
| 90 | 90 | function lsx_team_shortcode( $atts ) { |
| 91 | - $lsx_team = new LSX_Team; |
|
| 92 | - return $lsx_team->output( $atts ); |
|
| 91 | + $lsx_team = new LSX_Team; |
|
| 92 | + return $lsx_team->output( $atts ); |
|
| 93 | 93 | } |
| 94 | 94 | add_shortcode( 'lsx_team', 'lsx_team_shortcode' ); |
| 95 | 95 | |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | * @param [type] $request request. |
| 102 | 102 | */ |
| 103 | 103 | function lsx_team_get_images_urls( $object, $field_name, $request ) { |
| 104 | - $medium = wp_get_attachment_image_src( get_post_thumbnail_id( $object->id ), 'medium' ); |
|
| 105 | - $medium_url = $medium['0']; |
|
| 104 | + $medium = wp_get_attachment_image_src( get_post_thumbnail_id( $object->id ), 'medium' ); |
|
| 105 | + $medium_url = $medium['0']; |
|
| 106 | 106 | |
| 107 | - $large = wp_get_attachment_image_src( get_post_thumbnail_id( $object->id ), 'large' ); |
|
| 108 | - $large_url = $large['0']; |
|
| 107 | + $large = wp_get_attachment_image_src( get_post_thumbnail_id( $object->id ), 'large' ); |
|
| 108 | + $large_url = $large['0']; |
|
| 109 | 109 | |
| 110 | - return array( |
|
| 111 | - 'medium' => $medium_url, |
|
| 112 | - 'large' => $large_url, |
|
| 113 | - ); |
|
| 110 | + return array( |
|
| 111 | + 'medium' => $medium_url, |
|
| 112 | + 'large' => $large_url, |
|
| 113 | + ); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -119,15 +119,15 @@ discard block |
||
| 119 | 119 | * @return void |
| 120 | 120 | */ |
| 121 | 121 | function lsx_team_register_images_field() { |
| 122 | - register_rest_field( |
|
| 123 | - 'team', |
|
| 124 | - 'images', |
|
| 125 | - array( |
|
| 126 | - 'get_callback' => 'lsx_team_get_images_urls', |
|
| 127 | - 'update_callback' => null, |
|
| 128 | - 'schema' => null, |
|
| 129 | - ) |
|
| 130 | - ); |
|
| 122 | + register_rest_field( |
|
| 123 | + 'team', |
|
| 124 | + 'images', |
|
| 125 | + array( |
|
| 126 | + 'get_callback' => 'lsx_team_get_images_urls', |
|
| 127 | + 'update_callback' => null, |
|
| 128 | + 'schema' => null, |
|
| 129 | + ) |
|
| 130 | + ); |
|
| 131 | 131 | } |
| 132 | 132 | add_action( 'rest_api_init', 'lsx_team_register_images_field' ); |
| 133 | 133 | |
@@ -139,25 +139,25 @@ discard block |
||
| 139 | 139 | * @param [type] $request request. |
| 140 | 140 | */ |
| 141 | 141 | function lsx_team_get_additional_meta( $object, $field_name, $request ) { |
| 142 | - $role = get_the_terms( get_the_ID(), 'team_role' ); |
|
| 143 | - $job_title = get_post_meta( get_the_ID(), 'lsx_job_title', true ); |
|
| 144 | - $email = get_post_meta( get_the_ID(), 'lsx_email_contact', true ); |
|
| 145 | - $phone = get_post_meta( get_the_ID(), 'lsx_tel', true ); |
|
| 146 | - $skype = get_post_meta( get_the_ID(), 'lsx_skype', true ); |
|
| 147 | - $facebook = get_post_meta( get_the_ID(), 'lsx_facebook', true ); |
|
| 148 | - $twitter = get_post_meta( get_the_ID(), 'lsx_twitter', true ); |
|
| 149 | - $linkedin = get_post_meta( get_the_ID(), 'lsx_linkedin', true ); |
|
| 150 | - |
|
| 151 | - return array( |
|
| 152 | - 'role' => $role, |
|
| 153 | - 'job_title' => $job_title, |
|
| 154 | - 'email' => $email, |
|
| 155 | - 'phone' => $phone, |
|
| 156 | - 'skype' => $skype, |
|
| 157 | - 'facebook' => $facebook, |
|
| 158 | - 'twitter' => $twitter, |
|
| 159 | - 'linkedin' => $linkedin, |
|
| 160 | - ); |
|
| 142 | + $role = get_the_terms( get_the_ID(), 'team_role' ); |
|
| 143 | + $job_title = get_post_meta( get_the_ID(), 'lsx_job_title', true ); |
|
| 144 | + $email = get_post_meta( get_the_ID(), 'lsx_email_contact', true ); |
|
| 145 | + $phone = get_post_meta( get_the_ID(), 'lsx_tel', true ); |
|
| 146 | + $skype = get_post_meta( get_the_ID(), 'lsx_skype', true ); |
|
| 147 | + $facebook = get_post_meta( get_the_ID(), 'lsx_facebook', true ); |
|
| 148 | + $twitter = get_post_meta( get_the_ID(), 'lsx_twitter', true ); |
|
| 149 | + $linkedin = get_post_meta( get_the_ID(), 'lsx_linkedin', true ); |
|
| 150 | + |
|
| 151 | + return array( |
|
| 152 | + 'role' => $role, |
|
| 153 | + 'job_title' => $job_title, |
|
| 154 | + 'email' => $email, |
|
| 155 | + 'phone' => $phone, |
|
| 156 | + 'skype' => $skype, |
|
| 157 | + 'facebook' => $facebook, |
|
| 158 | + 'twitter' => $twitter, |
|
| 159 | + 'linkedin' => $linkedin, |
|
| 160 | + ); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -166,14 +166,14 @@ discard block |
||
| 166 | 166 | * @return void |
| 167 | 167 | */ |
| 168 | 168 | function lsx_team_register_additional_meta() { |
| 169 | - register_rest_field( |
|
| 170 | - 'team', |
|
| 171 | - 'additional_meta', |
|
| 172 | - array( |
|
| 173 | - 'get_callback' => 'lsx_team_get_additional_meta', |
|
| 174 | - 'update_callback' => null, |
|
| 175 | - 'schema' => null, |
|
| 176 | - ) |
|
| 177 | - ); |
|
| 169 | + register_rest_field( |
|
| 170 | + 'team', |
|
| 171 | + 'additional_meta', |
|
| 172 | + array( |
|
| 173 | + 'get_callback' => 'lsx_team_get_additional_meta', |
|
| 174 | + 'update_callback' => null, |
|
| 175 | + 'schema' => null, |
|
| 176 | + ) |
|
| 177 | + ); |
|
| 178 | 178 | } |
| 179 | 179 | add_action( 'rest_api_init', 'lsx_team_register_additional_meta' ); |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | // If this file is called directly, abort. |
| 16 | 16 | if ( ! defined( 'WPINC' ) ) { |
| 17 | - die; |
|
| 17 | + die; |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | define( 'LSX_TEAM_PATH', plugin_dir_path( __FILE__ ) ); |
@@ -6,12 +6,12 @@ |
||
| 6 | 6 | |
| 7 | 7 | <?php if ( ! empty( team_get_option( 'team_careers_cta_enable' ) ) ) : ?> |
| 8 | 8 | <?php |
| 9 | - $thumbnail = '<img loading="lazy" class="img-responsive wp-post-image" src="https://www.gravatar.com/avatar/none?d=mm&s=170" width="170" />'; |
|
| 10 | - $title = team_get_option( 'team_careers_cta_title' ); |
|
| 11 | - $tagline = team_get_option( 'team_careers_cta_tagline' ); |
|
| 12 | - $link_text = team_get_option( 'team_careers_cta_link_text' ); |
|
| 13 | - $link = team_get_option( 'team_careers_cta_link' ); |
|
| 14 | - ?> |
|
| 9 | + $thumbnail = '<img loading="lazy" class="img-responsive wp-post-image" src="https://www.gravatar.com/avatar/none?d=mm&s=170" width="170" />'; |
|
| 10 | + $title = team_get_option( 'team_careers_cta_title' ); |
|
| 11 | + $tagline = team_get_option( 'team_careers_cta_tagline' ); |
|
| 12 | + $link_text = team_get_option( 'team_careers_cta_link_text' ); |
|
| 13 | + $link = team_get_option( 'team_careers_cta_link' ); |
|
| 14 | + ?> |
|
| 15 | 15 | |
| 16 | 16 | <div class="col-xs-12 col-sm-6 col-md-3"> |
| 17 | 17 | <article class="lsx-team-slot"> |
@@ -5,11 +5,11 @@ discard block |
||
| 5 | 5 | ?> |
| 6 | 6 | |
| 7 | 7 | <?php |
| 8 | - global $lsx_team; |
|
| 8 | + global $lsx_team; |
|
| 9 | 9 | |
| 10 | - $thumbnail = $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-archive' ); |
|
| 10 | + $thumbnail = $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-archive' ); |
|
| 11 | 11 | |
| 12 | - $job_title = get_post_meta( get_the_ID(), 'lsx_job_title', true ); |
|
| 12 | + $job_title = get_post_meta( get_the_ID(), 'lsx_job_title', true ); |
|
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | 15 | <?php lsx_entry_before(); ?> |
@@ -44,4 +44,4 @@ discard block |
||
| 44 | 44 | </div> |
| 45 | 45 | |
| 46 | 46 | <?php |
| 47 | - lsx_entry_after(); |
|
| 47 | + lsx_entry_after(); |
|
@@ -23,13 +23,13 @@ |
||
| 23 | 23 | <div class="row row-flex"> |
| 24 | 24 | |
| 25 | 25 | <?php |
| 26 | - while ( have_posts() ) { |
|
| 27 | - the_post(); |
|
| 28 | - include( LSX_TEAM_PATH . '/templates/content-archive-team.php' ); |
|
| 29 | - } |
|
| 26 | + while ( have_posts() ) { |
|
| 27 | + the_post(); |
|
| 28 | + include( LSX_TEAM_PATH . '/templates/content-archive-team.php' ); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - include( LSX_TEAM_PATH . '/templates/content-archive-team-careers-cta.php' ); |
|
| 32 | - ?> |
|
| 31 | + include( LSX_TEAM_PATH . '/templates/content-archive-team-careers-cta.php' ); |
|
| 32 | + ?> |
|
| 33 | 33 | |
| 34 | 34 | </div> |
| 35 | 35 | </div> |
@@ -10,56 +10,56 @@ |
||
| 10 | 10 | * @since 10.2 |
| 11 | 11 | */ |
| 12 | 12 | class LSX_Team_Schema extends LSX_Schema_Graph_Piece { |
| 13 | - /** |
|
| 14 | - * Constructor. |
|
| 15 | - * |
|
| 16 | - * @param \WPSEO_Schema_Context $context A value object with context variables. |
|
| 17 | - */ |
|
| 18 | - public function __construct( WPSEO_Schema_Context $context ) { |
|
| 19 | - $this->post_type = 'team'; |
|
| 20 | - parent::__construct( $context ); |
|
| 21 | - } |
|
| 22 | - /** |
|
| 23 | - * Returns Review data. |
|
| 24 | - * |
|
| 25 | - * @return array $data Review data. |
|
| 26 | - */ |
|
| 27 | - public function generate() { |
|
| 28 | - $data = array( |
|
| 29 | - '@type' => array( |
|
| 30 | - 'Person', |
|
| 31 | - ), |
|
| 32 | - '@id' => $this->context->canonical . '#person', |
|
| 33 | - 'name' => $this->post->post_title, |
|
| 34 | - 'description' => wp_strip_all_tags( $this->post->post_content ), |
|
| 35 | - 'url' => $this->post_url, |
|
| 36 | - 'mainEntityOfPage' => array( |
|
| 37 | - '@id' => $this->context->canonical . WPSEO_Schema_IDs::WEBPAGE_HASH, |
|
| 38 | - ), |
|
| 39 | - ); |
|
| 40 | - if ( $this->context->site_represents_reference ) { |
|
| 41 | - $data['worksFor'] = $this->context->site_represents_reference; |
|
| 42 | - $data['memberOf'] = $this->context->site_represents_reference; |
|
| 43 | - } |
|
| 44 | - $data = $this->add_custom_field( $data, 'jobTitle', 'lsx_job_title' ); |
|
| 45 | - $data = $this->add_custom_field( $data, 'email', 'lsx_email_contact' ); |
|
| 46 | - $data = $this->add_custom_field( $data, 'telephone', 'lsx_tel' ); |
|
| 47 | - $data = LSX_Schema_Utils::add_image( $data, $this->context ); |
|
| 48 | - return $data; |
|
| 49 | - } |
|
| 50 | - /** |
|
| 51 | - * Adds the projects and testimonials under the 'owns' parameter |
|
| 52 | - * |
|
| 53 | - * @param array $data |
|
| 54 | - * @return array |
|
| 55 | - */ |
|
| 56 | - public function add_products( $data ) { |
|
| 57 | - $connections_array = array(); |
|
| 58 | - $connections_array = $this->add_project( $connections_array ); |
|
| 59 | - $connections_array = $this->add_testimonial( $connections_array ); |
|
| 60 | - if ( ! empty( $connections_array ) ) { |
|
| 61 | - $data['owns'] = $connections_array; |
|
| 62 | - } |
|
| 63 | - return $data; |
|
| 64 | - } |
|
| 13 | + /** |
|
| 14 | + * Constructor. |
|
| 15 | + * |
|
| 16 | + * @param \WPSEO_Schema_Context $context A value object with context variables. |
|
| 17 | + */ |
|
| 18 | + public function __construct( WPSEO_Schema_Context $context ) { |
|
| 19 | + $this->post_type = 'team'; |
|
| 20 | + parent::__construct( $context ); |
|
| 21 | + } |
|
| 22 | + /** |
|
| 23 | + * Returns Review data. |
|
| 24 | + * |
|
| 25 | + * @return array $data Review data. |
|
| 26 | + */ |
|
| 27 | + public function generate() { |
|
| 28 | + $data = array( |
|
| 29 | + '@type' => array( |
|
| 30 | + 'Person', |
|
| 31 | + ), |
|
| 32 | + '@id' => $this->context->canonical . '#person', |
|
| 33 | + 'name' => $this->post->post_title, |
|
| 34 | + 'description' => wp_strip_all_tags( $this->post->post_content ), |
|
| 35 | + 'url' => $this->post_url, |
|
| 36 | + 'mainEntityOfPage' => array( |
|
| 37 | + '@id' => $this->context->canonical . WPSEO_Schema_IDs::WEBPAGE_HASH, |
|
| 38 | + ), |
|
| 39 | + ); |
|
| 40 | + if ( $this->context->site_represents_reference ) { |
|
| 41 | + $data['worksFor'] = $this->context->site_represents_reference; |
|
| 42 | + $data['memberOf'] = $this->context->site_represents_reference; |
|
| 43 | + } |
|
| 44 | + $data = $this->add_custom_field( $data, 'jobTitle', 'lsx_job_title' ); |
|
| 45 | + $data = $this->add_custom_field( $data, 'email', 'lsx_email_contact' ); |
|
| 46 | + $data = $this->add_custom_field( $data, 'telephone', 'lsx_tel' ); |
|
| 47 | + $data = LSX_Schema_Utils::add_image( $data, $this->context ); |
|
| 48 | + return $data; |
|
| 49 | + } |
|
| 50 | + /** |
|
| 51 | + * Adds the projects and testimonials under the 'owns' parameter |
|
| 52 | + * |
|
| 53 | + * @param array $data |
|
| 54 | + * @return array |
|
| 55 | + */ |
|
| 56 | + public function add_products( $data ) { |
|
| 57 | + $connections_array = array(); |
|
| 58 | + $connections_array = $this->add_project( $connections_array ); |
|
| 59 | + $connections_array = $this->add_testimonial( $connections_array ); |
|
| 60 | + if ( ! empty( $connections_array ) ) { |
|
| 61 | + $data['owns'] = $connections_array; |
|
| 62 | + } |
|
| 63 | + return $data; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -10,191 +10,191 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | class LSX_Team_Widget extends WP_Widget { |
| 12 | 12 | |
| 13 | - public function __construct() { |
|
| 14 | - $widget_ops = array( |
|
| 15 | - 'classname' => 'lsx-team', |
|
| 16 | - ); |
|
| 13 | + public function __construct() { |
|
| 14 | + $widget_ops = array( |
|
| 15 | + 'classname' => 'lsx-team', |
|
| 16 | + ); |
|
| 17 | 17 | |
| 18 | - parent::__construct( 'LSX_Team_Widget', esc_html__( 'LSX Team Members', 'lsx-team' ), $widget_ops ); |
|
| 19 | - } |
|
| 18 | + parent::__construct( 'LSX_Team_Widget', esc_html__( 'LSX Team Members', 'lsx-team' ), $widget_ops ); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function widget( $args, $instance ) { |
|
| 22 | - extract( $args ); |
|
| 21 | + public function widget( $args, $instance ) { |
|
| 22 | + extract( $args ); |
|
| 23 | 23 | |
| 24 | - $title = $instance['title']; |
|
| 25 | - $title_link = $instance['title_link']; |
|
| 26 | - $tagline = $instance['tagline']; |
|
| 27 | - $columns = $instance['columns']; |
|
| 28 | - $orderby = $instance['orderby']; |
|
| 29 | - $order = $instance['order']; |
|
| 30 | - $role = $instance['role']; |
|
| 31 | - $limit = $instance['limit']; |
|
| 32 | - $include = $instance['include']; |
|
| 33 | - $display = $instance['display']; |
|
| 34 | - $size = $instance['size']; |
|
| 35 | - $show_link = $instance['show_link']; |
|
| 36 | - $show_image = $instance['show_image']; |
|
| 37 | - $show_roles = $instance['show_roles']; |
|
| 38 | - $show_job_title = $instance['show_job_title']; |
|
| 39 | - $show_desc = $instance['show_desc']; |
|
| 40 | - $show_social = $instance['show_social']; |
|
| 41 | - $button_text = $instance['button_text']; |
|
| 42 | - $carousel = $instance['carousel']; |
|
| 43 | - $featured = $instance['featured']; |
|
| 24 | + $title = $instance['title']; |
|
| 25 | + $title_link = $instance['title_link']; |
|
| 26 | + $tagline = $instance['tagline']; |
|
| 27 | + $columns = $instance['columns']; |
|
| 28 | + $orderby = $instance['orderby']; |
|
| 29 | + $order = $instance['order']; |
|
| 30 | + $role = $instance['role']; |
|
| 31 | + $limit = $instance['limit']; |
|
| 32 | + $include = $instance['include']; |
|
| 33 | + $display = $instance['display']; |
|
| 34 | + $size = $instance['size']; |
|
| 35 | + $show_link = $instance['show_link']; |
|
| 36 | + $show_image = $instance['show_image']; |
|
| 37 | + $show_roles = $instance['show_roles']; |
|
| 38 | + $show_job_title = $instance['show_job_title']; |
|
| 39 | + $show_desc = $instance['show_desc']; |
|
| 40 | + $show_social = $instance['show_social']; |
|
| 41 | + $button_text = $instance['button_text']; |
|
| 42 | + $carousel = $instance['carousel']; |
|
| 43 | + $featured = $instance['featured']; |
|
| 44 | 44 | |
| 45 | - // If limit not set, display 99 posts |
|
| 46 | - if ( empty( $limit ) ) { |
|
| 47 | - $limit = '99'; |
|
| 48 | - } |
|
| 45 | + // If limit not set, display 99 posts |
|
| 46 | + if ( empty( $limit ) ) { |
|
| 47 | + $limit = '99'; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - // If specific posts included, display 99 posts |
|
| 51 | - if ( ! empty( $include ) ) { |
|
| 52 | - $limit = '99'; |
|
| 53 | - } |
|
| 50 | + // If specific posts included, display 99 posts |
|
| 51 | + if ( ! empty( $include ) ) { |
|
| 52 | + $limit = '99'; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - // Disregard specific ID setting if specific role is defined |
|
| 56 | - if ( 'all' !== $role ) { |
|
| 57 | - $include = ''; |
|
| 58 | - } else { |
|
| 59 | - $role = ''; |
|
| 60 | - } |
|
| 55 | + // Disregard specific ID setting if specific role is defined |
|
| 56 | + if ( 'all' !== $role ) { |
|
| 57 | + $include = ''; |
|
| 58 | + } else { |
|
| 59 | + $role = ''; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $show_link = '1' == $show_link ? 'true' : 'false'; |
|
| 63 | - $show_image = '1' == $show_image ? 'true' : 'false'; |
|
| 64 | - $show_roles = '1' == $show_roles ? 'true' : 'false'; |
|
| 65 | - $show_job_title = '1' == $show_job_title ? 'true' : 'false'; |
|
| 66 | - $show_desc = '1' == $show_desc ? 'true' : 'false'; |
|
| 67 | - $show_social = '1' == $show_social ? 'true' : 'false'; |
|
| 68 | - $carousel = '1' == $carousel ? 'true' : 'false'; |
|
| 69 | - $featured = '1' == $featured ? 'true' : 'false'; |
|
| 62 | + $show_link = '1' == $show_link ? 'true' : 'false'; |
|
| 63 | + $show_image = '1' == $show_image ? 'true' : 'false'; |
|
| 64 | + $show_roles = '1' == $show_roles ? 'true' : 'false'; |
|
| 65 | + $show_job_title = '1' == $show_job_title ? 'true' : 'false'; |
|
| 66 | + $show_desc = '1' == $show_desc ? 'true' : 'false'; |
|
| 67 | + $show_social = '1' == $show_social ? 'true' : 'false'; |
|
| 68 | + $carousel = '1' == $carousel ? 'true' : 'false'; |
|
| 69 | + $featured = '1' == $featured ? 'true' : 'false'; |
|
| 70 | 70 | |
| 71 | - if ( $title_link ) { |
|
| 72 | - //$link_open = '<a href="' . $title_link . '">'; |
|
| 73 | - $link_open = ''; |
|
| 74 | - $link_btn_open = '<a href="' . $title_link . '" class="btn border-btn">'; |
|
| 75 | - //$link_close = '</a>'; |
|
| 76 | - $link_close = ''; |
|
| 77 | - $link_btn_close = '</a>'; |
|
| 78 | - } else { |
|
| 79 | - $link_open = ''; |
|
| 80 | - $link_btn_open = ''; |
|
| 81 | - $link_close = ''; |
|
| 82 | - $link_btn_close = ''; |
|
| 83 | - } |
|
| 71 | + if ( $title_link ) { |
|
| 72 | + //$link_open = '<a href="' . $title_link . '">'; |
|
| 73 | + $link_open = ''; |
|
| 74 | + $link_btn_open = '<a href="' . $title_link . '" class="btn border-btn">'; |
|
| 75 | + //$link_close = '</a>'; |
|
| 76 | + $link_close = ''; |
|
| 77 | + $link_btn_close = '</a>'; |
|
| 78 | + } else { |
|
| 79 | + $link_open = ''; |
|
| 80 | + $link_btn_open = ''; |
|
| 81 | + $link_close = ''; |
|
| 82 | + $link_btn_close = ''; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - echo wp_kses_post( $before_widget ); |
|
| 85 | + echo wp_kses_post( $before_widget ); |
|
| 86 | 86 | |
| 87 | - if ( $title ) { |
|
| 88 | - echo wp_kses_post( $before_title . $link_open . $title . $link_close . $after_title ); |
|
| 89 | - } |
|
| 87 | + if ( $title ) { |
|
| 88 | + echo wp_kses_post( $before_title . $link_open . $title . $link_close . $after_title ); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - if ( $tagline ) { |
|
| 92 | - echo '<p class="tagline text-center">' . esc_html( $tagline ) . '</p>'; |
|
| 93 | - } |
|
| 91 | + if ( $tagline ) { |
|
| 92 | + echo '<p class="tagline text-center">' . esc_html( $tagline ) . '</p>'; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - if ( class_exists( 'LSX_Team' ) ) { |
|
| 96 | - lsx_team( array( |
|
| 97 | - 'columns' => $columns, |
|
| 98 | - 'orderby' => $orderby, |
|
| 99 | - 'order' => $order, |
|
| 100 | - 'role' => $role, |
|
| 101 | - 'limit' => $limit, |
|
| 102 | - 'include' => $include, |
|
| 103 | - 'display' => $display, |
|
| 104 | - 'size' => $size, |
|
| 105 | - 'show_link' => $show_link, |
|
| 106 | - 'show_image' => $show_image, |
|
| 107 | - 'show_roles' => $show_roles, |
|
| 108 | - 'show_job_title' => $show_job_title, |
|
| 109 | - 'show_desc' => $show_desc, |
|
| 110 | - 'show_social' => $show_social, |
|
| 111 | - 'carousel' => $carousel, |
|
| 112 | - 'featured' => $featured, |
|
| 113 | - ) ); |
|
| 95 | + if ( class_exists( 'LSX_Team' ) ) { |
|
| 96 | + lsx_team( array( |
|
| 97 | + 'columns' => $columns, |
|
| 98 | + 'orderby' => $orderby, |
|
| 99 | + 'order' => $order, |
|
| 100 | + 'role' => $role, |
|
| 101 | + 'limit' => $limit, |
|
| 102 | + 'include' => $include, |
|
| 103 | + 'display' => $display, |
|
| 104 | + 'size' => $size, |
|
| 105 | + 'show_link' => $show_link, |
|
| 106 | + 'show_image' => $show_image, |
|
| 107 | + 'show_roles' => $show_roles, |
|
| 108 | + 'show_job_title' => $show_job_title, |
|
| 109 | + 'show_desc' => $show_desc, |
|
| 110 | + 'show_social' => $show_social, |
|
| 111 | + 'carousel' => $carousel, |
|
| 112 | + 'featured' => $featured, |
|
| 113 | + ) ); |
|
| 114 | 114 | |
| 115 | - }; |
|
| 115 | + }; |
|
| 116 | 116 | |
| 117 | - if ( $button_text && $title_link ) { |
|
| 118 | - echo wp_kses_post( '<p class="text-center lsx-team-archive-link-wrap"><span class="lsx-team-archive-link">' . $link_btn_open . $button_text . ' <i class="fa fa-angle-right"></i>' . $link_btn_close . '</span></p>' ); |
|
| 119 | - } |
|
| 117 | + if ( $button_text && $title_link ) { |
|
| 118 | + echo wp_kses_post( '<p class="text-center lsx-team-archive-link-wrap"><span class="lsx-team-archive-link">' . $link_btn_open . $button_text . ' <i class="fa fa-angle-right"></i>' . $link_btn_close . '</span></p>' ); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - echo wp_kses_post( $after_widget ); |
|
| 122 | - } |
|
| 121 | + echo wp_kses_post( $after_widget ); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - public function update( $new_instance, $old_instance ) { |
|
| 125 | - $instance = $old_instance; |
|
| 124 | + public function update( $new_instance, $old_instance ) { |
|
| 125 | + $instance = $old_instance; |
|
| 126 | 126 | |
| 127 | - $instance['title'] = wp_kses_post( force_balance_tags( $new_instance['title'] ) ); |
|
| 128 | - $instance['title_link'] = strip_tags( $new_instance['title_link'] ); |
|
| 129 | - $instance['tagline'] = strip_tags( $new_instance['tagline'] ); |
|
| 130 | - $instance['columns'] = strip_tags( $new_instance['columns'] ); |
|
| 131 | - $instance['orderby'] = strip_tags( $new_instance['orderby'] ); |
|
| 132 | - $instance['order'] = strip_tags( $new_instance['order'] ); |
|
| 133 | - $instance['role'] = strip_tags( $new_instance['role'] ); |
|
| 134 | - $instance['limit'] = strip_tags( $new_instance['limit'] ); |
|
| 135 | - $instance['include'] = strip_tags( $new_instance['include'] ); |
|
| 136 | - $instance['display'] = strip_tags( $new_instance['display'] ); |
|
| 137 | - $instance['size'] = strip_tags( $new_instance['size'] ); |
|
| 138 | - $instance['show_link'] = strip_tags( $new_instance['show_link'] ); |
|
| 139 | - $instance['show_image'] = strip_tags( $new_instance['show_image'] ); |
|
| 140 | - $instance['show_roles'] = strip_tags( $new_instance['show_roles'] ); |
|
| 141 | - $instance['show_job_title'] = strip_tags( $new_instance['show_job_title'] ); |
|
| 142 | - $instance['show_desc'] = strip_tags( $new_instance['show_desc'] ); |
|
| 143 | - $instance['show_social'] = strip_tags( $new_instance['show_social'] ); |
|
| 144 | - $instance['button_text'] = strip_tags( $new_instance['button_text'] ); |
|
| 145 | - $instance['carousel'] = strip_tags( $new_instance['carousel'] ); |
|
| 146 | - $instance['featured'] = strip_tags( $new_instance['featured'] ); |
|
| 127 | + $instance['title'] = wp_kses_post( force_balance_tags( $new_instance['title'] ) ); |
|
| 128 | + $instance['title_link'] = strip_tags( $new_instance['title_link'] ); |
|
| 129 | + $instance['tagline'] = strip_tags( $new_instance['tagline'] ); |
|
| 130 | + $instance['columns'] = strip_tags( $new_instance['columns'] ); |
|
| 131 | + $instance['orderby'] = strip_tags( $new_instance['orderby'] ); |
|
| 132 | + $instance['order'] = strip_tags( $new_instance['order'] ); |
|
| 133 | + $instance['role'] = strip_tags( $new_instance['role'] ); |
|
| 134 | + $instance['limit'] = strip_tags( $new_instance['limit'] ); |
|
| 135 | + $instance['include'] = strip_tags( $new_instance['include'] ); |
|
| 136 | + $instance['display'] = strip_tags( $new_instance['display'] ); |
|
| 137 | + $instance['size'] = strip_tags( $new_instance['size'] ); |
|
| 138 | + $instance['show_link'] = strip_tags( $new_instance['show_link'] ); |
|
| 139 | + $instance['show_image'] = strip_tags( $new_instance['show_image'] ); |
|
| 140 | + $instance['show_roles'] = strip_tags( $new_instance['show_roles'] ); |
|
| 141 | + $instance['show_job_title'] = strip_tags( $new_instance['show_job_title'] ); |
|
| 142 | + $instance['show_desc'] = strip_tags( $new_instance['show_desc'] ); |
|
| 143 | + $instance['show_social'] = strip_tags( $new_instance['show_social'] ); |
|
| 144 | + $instance['button_text'] = strip_tags( $new_instance['button_text'] ); |
|
| 145 | + $instance['carousel'] = strip_tags( $new_instance['carousel'] ); |
|
| 146 | + $instance['featured'] = strip_tags( $new_instance['featured'] ); |
|
| 147 | 147 | |
| 148 | - return $instance; |
|
| 149 | - } |
|
| 148 | + return $instance; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - public function form( $instance ) { |
|
| 152 | - $defaults = array( |
|
| 153 | - 'title' => 'Team Members', |
|
| 154 | - 'title_link' => '', |
|
| 155 | - 'tagline' => '', |
|
| 156 | - 'columns' => '1', |
|
| 157 | - 'orderby' => 'name', |
|
| 158 | - 'order' => 'ASC', |
|
| 159 | - 'role' => '', |
|
| 160 | - 'limit' => '', |
|
| 161 | - 'include' => '', |
|
| 162 | - 'display' => 'excerpt', |
|
| 163 | - 'size' => 'lsx-team-archive', |
|
| 164 | - 'show_link' => 0, |
|
| 165 | - 'show_image' => 1, |
|
| 166 | - 'show_roles' => 0, |
|
| 167 | - 'show_job_title' => 1, |
|
| 168 | - 'show_desc' => 1, |
|
| 169 | - 'show_social' => 1, |
|
| 170 | - 'button_text' => '', |
|
| 171 | - 'carousel' => 1, |
|
| 172 | - 'featured' => 0, |
|
| 173 | - ); |
|
| 151 | + public function form( $instance ) { |
|
| 152 | + $defaults = array( |
|
| 153 | + 'title' => 'Team Members', |
|
| 154 | + 'title_link' => '', |
|
| 155 | + 'tagline' => '', |
|
| 156 | + 'columns' => '1', |
|
| 157 | + 'orderby' => 'name', |
|
| 158 | + 'order' => 'ASC', |
|
| 159 | + 'role' => '', |
|
| 160 | + 'limit' => '', |
|
| 161 | + 'include' => '', |
|
| 162 | + 'display' => 'excerpt', |
|
| 163 | + 'size' => 'lsx-team-archive', |
|
| 164 | + 'show_link' => 0, |
|
| 165 | + 'show_image' => 1, |
|
| 166 | + 'show_roles' => 0, |
|
| 167 | + 'show_job_title' => 1, |
|
| 168 | + 'show_desc' => 1, |
|
| 169 | + 'show_social' => 1, |
|
| 170 | + 'button_text' => '', |
|
| 171 | + 'carousel' => 1, |
|
| 172 | + 'featured' => 0, |
|
| 173 | + ); |
|
| 174 | 174 | |
| 175 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
| 175 | + $instance = wp_parse_args( (array) $instance, $defaults ); |
|
| 176 | 176 | |
| 177 | - $title = esc_attr( $instance['title'] ); |
|
| 178 | - $title_link = esc_attr( $instance['title_link'] ); |
|
| 179 | - $tagline = esc_attr( $instance['tagline'] ); |
|
| 180 | - $columns = esc_attr( $instance['columns'] ); |
|
| 181 | - $orderby = esc_attr( $instance['orderby'] ); |
|
| 182 | - $order = esc_attr( $instance['order'] ); |
|
| 183 | - $role = esc_attr( $instance['role'] ); |
|
| 184 | - $limit = esc_attr( $instance['limit'] ); |
|
| 185 | - $include = esc_attr( $instance['include'] ); |
|
| 186 | - $display = esc_attr( $instance['display'] ); |
|
| 187 | - $size = esc_attr( $instance['size'] ); |
|
| 188 | - $show_link = esc_attr( $instance['show_link'] ); |
|
| 189 | - $show_image = esc_attr( $instance['show_image'] ); |
|
| 190 | - $show_roles = esc_attr( $instance['show_roles'] ); |
|
| 191 | - $show_job_title = esc_attr( $instance['show_job_title'] ); |
|
| 192 | - $show_desc = esc_attr( $instance['show_desc'] ); |
|
| 193 | - $show_social = esc_attr( $instance['show_social'] ); |
|
| 194 | - $button_text = esc_attr( $instance['button_text'] ); |
|
| 195 | - $carousel = esc_attr( $instance['carousel'] ); |
|
| 196 | - $featured = esc_attr( $instance['featured'] ); |
|
| 197 | - ?> |
|
| 177 | + $title = esc_attr( $instance['title'] ); |
|
| 178 | + $title_link = esc_attr( $instance['title_link'] ); |
|
| 179 | + $tagline = esc_attr( $instance['tagline'] ); |
|
| 180 | + $columns = esc_attr( $instance['columns'] ); |
|
| 181 | + $orderby = esc_attr( $instance['orderby'] ); |
|
| 182 | + $order = esc_attr( $instance['order'] ); |
|
| 183 | + $role = esc_attr( $instance['role'] ); |
|
| 184 | + $limit = esc_attr( $instance['limit'] ); |
|
| 185 | + $include = esc_attr( $instance['include'] ); |
|
| 186 | + $display = esc_attr( $instance['display'] ); |
|
| 187 | + $size = esc_attr( $instance['size'] ); |
|
| 188 | + $show_link = esc_attr( $instance['show_link'] ); |
|
| 189 | + $show_image = esc_attr( $instance['show_image'] ); |
|
| 190 | + $show_roles = esc_attr( $instance['show_roles'] ); |
|
| 191 | + $show_job_title = esc_attr( $instance['show_job_title'] ); |
|
| 192 | + $show_desc = esc_attr( $instance['show_desc'] ); |
|
| 193 | + $show_social = esc_attr( $instance['show_social'] ); |
|
| 194 | + $button_text = esc_attr( $instance['button_text'] ); |
|
| 195 | + $carousel = esc_attr( $instance['carousel'] ); |
|
| 196 | + $featured = esc_attr( $instance['featured'] ); |
|
| 197 | + ?> |
|
| 198 | 198 | <p> |
| 199 | 199 | <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'lsx-team' ); ?></label> |
| 200 | 200 | <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> |
@@ -213,63 +213,63 @@ discard block |
||
| 213 | 213 | <label for="<?php echo esc_attr( $this->get_field_id( 'columns' ) ); ?>"><?php esc_html_e( 'Columns:', 'lsx-team' ); ?></label> |
| 214 | 214 | <select name="<?php echo esc_attr( $this->get_field_name( 'columns' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'columns' ) ); ?>" class="widefat layout"> |
| 215 | 215 | <?php |
| 216 | - $options = array( '1', '2', '3', '4' ); |
|
| 216 | + $options = array( '1', '2', '3', '4' ); |
|
| 217 | 217 | |
| 218 | - foreach ( $options as $option ) { |
|
| 219 | - echo '<option value="' . lcfirst( esc_attr( $option ) ) . '" id="' . esc_attr( $option ) . '"', lcfirst( $option ) == $columns ? ' selected="selected"' : '', '>', esc_html( $option ), '</option>'; |
|
| 220 | - } |
|
| 221 | - ?> |
|
| 218 | + foreach ( $options as $option ) { |
|
| 219 | + echo '<option value="' . lcfirst( esc_attr( $option ) ) . '" id="' . esc_attr( $option ) . '"', lcfirst( $option ) == $columns ? ' selected="selected"' : '', '>', esc_html( $option ), '</option>'; |
|
| 220 | + } |
|
| 221 | + ?> |
|
| 222 | 222 | </select> |
| 223 | 223 | </p> |
| 224 | 224 | <p> |
| 225 | 225 | <label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php esc_html_e( 'Order By:', 'lsx-team' ); ?></label> |
| 226 | 226 | <select name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" class="widefat"> |
| 227 | 227 | <?php |
| 228 | - $options = array( |
|
| 229 | - esc_html__( 'None', 'lsx-team' ) => 'none', |
|
| 230 | - esc_html__( 'ID', 'lsx-team' ) => 'ID', |
|
| 231 | - esc_html__( 'Name', 'lsx-team' ) => 'name', |
|
| 232 | - esc_html__( 'Date', 'lsx-team' ) => 'date', |
|
| 233 | - esc_html__( 'Modified Date', 'lsx-team' ) => 'modified', |
|
| 234 | - esc_html__( 'Random', 'lsx-team' ) => 'rand', |
|
| 235 | - esc_html__( 'Menu (WP dashboard order)', 'lsx-team' ) => 'menu_order', |
|
| 236 | - ); |
|
| 228 | + $options = array( |
|
| 229 | + esc_html__( 'None', 'lsx-team' ) => 'none', |
|
| 230 | + esc_html__( 'ID', 'lsx-team' ) => 'ID', |
|
| 231 | + esc_html__( 'Name', 'lsx-team' ) => 'name', |
|
| 232 | + esc_html__( 'Date', 'lsx-team' ) => 'date', |
|
| 233 | + esc_html__( 'Modified Date', 'lsx-team' ) => 'modified', |
|
| 234 | + esc_html__( 'Random', 'lsx-team' ) => 'rand', |
|
| 235 | + esc_html__( 'Menu (WP dashboard order)', 'lsx-team' ) => 'menu_order', |
|
| 236 | + ); |
|
| 237 | 237 | |
| 238 | - foreach ( $options as $name => $value ) { |
|
| 239 | - echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $orderby == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>'; |
|
| 240 | - } |
|
| 241 | - ?> |
|
| 238 | + foreach ( $options as $name => $value ) { |
|
| 239 | + echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $orderby == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>'; |
|
| 240 | + } |
|
| 241 | + ?> |
|
| 242 | 242 | </select> |
| 243 | 243 | </p> |
| 244 | 244 | <p> |
| 245 | 245 | <label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"><?php esc_html_e( 'Order:', 'lsx-team' ); ?></label> |
| 246 | 246 | <select name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>" class="widefat"> |
| 247 | 247 | <?php |
| 248 | - $options = array( |
|
| 249 | - esc_html__( 'Ascending', 'lsx-team' ) => 'ASC', |
|
| 250 | - esc_html__( 'Descending', 'lsx-team' ) => 'DESC', |
|
| 251 | - ); |
|
| 248 | + $options = array( |
|
| 249 | + esc_html__( 'Ascending', 'lsx-team' ) => 'ASC', |
|
| 250 | + esc_html__( 'Descending', 'lsx-team' ) => 'DESC', |
|
| 251 | + ); |
|
| 252 | 252 | |
| 253 | - foreach ( $options as $name => $value ) { |
|
| 254 | - echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $order == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>'; |
|
| 255 | - } |
|
| 256 | - ?> |
|
| 253 | + foreach ( $options as $name => $value ) { |
|
| 254 | + echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $order == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>'; |
|
| 255 | + } |
|
| 256 | + ?> |
|
| 257 | 257 | </select> |
| 258 | 258 | </p> |
| 259 | 259 | <p> |
| 260 | 260 | <label for="<?php echo esc_attr( $this->get_field_id( 'role' ) ); ?>"><?php esc_html_e( 'Role:', 'lsx-team' ); ?></label> |
| 261 | 261 | <select name="<?php echo esc_attr( $this->get_field_name( 'role' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'role' ) ); ?>" class="widefat"> |
| 262 | 262 | <?php |
| 263 | - $options = get_terms( 'team_role' ); |
|
| 264 | - ?> |
|
| 263 | + $options = get_terms( 'team_role' ); |
|
| 264 | + ?> |
|
| 265 | 265 | <option value="all" id="all"> |
| 266 | 266 | <?php esc_html_e( 'All Roles', 'lsx-team' ); ?> |
| 267 | 267 | </option> |
| 268 | 268 | <?php |
| 269 | - foreach ( $options as $option ) { |
|
| 270 | - echo '<option value="' . esc_attr( $option->slug ) . '" id="' . esc_attr( $option->slug ) . '"', $role == $option->slug ? ' selected="selected"' : '', '>', esc_html( $option->name ), '</option>'; |
|
| 271 | - } |
|
| 272 | - ?> |
|
| 269 | + foreach ( $options as $option ) { |
|
| 270 | + echo '<option value="' . esc_attr( $option->slug ) . '" id="' . esc_attr( $option->slug ) . '"', $role == $option->slug ? ' selected="selected"' : '', '>', esc_html( $option->name ), '</option>'; |
|
| 271 | + } |
|
| 272 | + ?> |
|
| 273 | 273 | </select> |
| 274 | 274 | <small><?php esc_html_e( 'Display team members within a specific role', 'lsx-team' ); ?></small> |
| 275 | 275 | </p> |
@@ -287,15 +287,15 @@ discard block |
||
| 287 | 287 | <label for="<?php echo esc_attr( $this->get_field_id( 'display' ) ); ?>"><?php esc_html_e( 'Display:', 'lsx-team' ); ?></label> |
| 288 | 288 | <select name="<?php echo esc_attr( $this->get_field_name( 'display' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'display' ) ); ?>" class="widefat"> |
| 289 | 289 | <?php |
| 290 | - $options = array( |
|
| 291 | - esc_html__( 'Excerpt', 'lsx-team' ) => 'excerpt', |
|
| 292 | - esc_html__( 'Full Content', 'lsx-team' ) => 'full', |
|
| 293 | - ); |
|
| 290 | + $options = array( |
|
| 291 | + esc_html__( 'Excerpt', 'lsx-team' ) => 'excerpt', |
|
| 292 | + esc_html__( 'Full Content', 'lsx-team' ) => 'full', |
|
| 293 | + ); |
|
| 294 | 294 | |
| 295 | - foreach ( $options as $name => $value ) { |
|
| 296 | - echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $display == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>'; |
|
| 297 | - } |
|
| 298 | - ?> |
|
| 295 | + foreach ( $options as $name => $value ) { |
|
| 296 | + echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $display == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>'; |
|
| 297 | + } |
|
| 298 | + ?> |
|
| 299 | 299 | </select> |
| 300 | 300 | </p> |
| 301 | 301 | <p> |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | <label for="<?php echo esc_attr( $this->get_field_id( 'featured' ) ); ?>"><?php esc_html_e( 'Featured posts', 'lsx-team' ); ?></label> |
| 341 | 341 | </p> |
| 342 | 342 | <?php |
| 343 | - } |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | 345 | } |
| 346 | 346 | |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | * Registers the Widget |
| 349 | 349 | */ |
| 350 | 350 | function lsx_team_widget() { |
| 351 | - register_widget( 'LSX_Team_Widget' ); |
|
| 351 | + register_widget( 'LSX_Team_Widget' ); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | add_action( 'widgets_init', 'lsx_team_widget' ); |
@@ -7,86 +7,86 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class LSX_Team_Core { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * Holds class instance |
|
| 12 | - * |
|
| 13 | - * @since 1.0.0 |
|
| 14 | - * |
|
| 15 | - * @var object LSX_Team_Core() |
|
| 16 | - */ |
|
| 17 | - protected static $instance = null; |
|
| 10 | + /** |
|
| 11 | + * Holds class instance |
|
| 12 | + * |
|
| 13 | + * @since 1.0.0 |
|
| 14 | + * |
|
| 15 | + * @var object LSX_Team_Core() |
|
| 16 | + */ |
|
| 17 | + protected static $instance = null; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Holds class instance |
|
| 21 | - * |
|
| 22 | - * @since 1.0.0 |
|
| 23 | - * |
|
| 24 | - * @var object \MAG_CMB2_Field_Post_Search_Ajax() |
|
| 25 | - */ |
|
| 26 | - public $cmb2_post_search_ajax = false; |
|
| 19 | + /** |
|
| 20 | + * Holds class instance |
|
| 21 | + * |
|
| 22 | + * @since 1.0.0 |
|
| 23 | + * |
|
| 24 | + * @var object \MAG_CMB2_Field_Post_Search_Ajax() |
|
| 25 | + */ |
|
| 26 | + public $cmb2_post_search_ajax = false; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Contructor |
|
| 30 | - */ |
|
| 31 | - public function __construct() { |
|
| 32 | - add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) ); |
|
| 33 | - $this->load_vendors(); |
|
| 34 | - } |
|
| 28 | + /** |
|
| 29 | + * Contructor |
|
| 30 | + */ |
|
| 31 | + public function __construct() { |
|
| 32 | + add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) ); |
|
| 33 | + $this->load_vendors(); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Return an instance of this class. |
|
| 38 | - * |
|
| 39 | - * @since 1.0.0 |
|
| 40 | - * |
|
| 41 | - * @return object \lsx_team\classes\Core() A single instance of this class. |
|
| 42 | - */ |
|
| 43 | - public static function get_instance() { |
|
| 36 | + /** |
|
| 37 | + * Return an instance of this class. |
|
| 38 | + * |
|
| 39 | + * @since 1.0.0 |
|
| 40 | + * |
|
| 41 | + * @return object \lsx_team\classes\Core() A single instance of this class. |
|
| 42 | + */ |
|
| 43 | + public static function get_instance() { |
|
| 44 | 44 | |
| 45 | - // If the single instance hasn't been set, set it now. |
|
| 46 | - if ( null === self::$instance ) { |
|
| 47 | - self::$instance = new self(); |
|
| 48 | - } |
|
| 45 | + // If the single instance hasn't been set, set it now. |
|
| 46 | + if ( null === self::$instance ) { |
|
| 47 | + self::$instance = new self(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return self::$instance; |
|
| 50 | + return self::$instance; |
|
| 51 | 51 | |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Loads the plugin functions. |
|
| 56 | - */ |
|
| 57 | - private function load_vendors() { |
|
| 58 | - // Configure custom fields. |
|
| 59 | - if ( ! class_exists( 'CMB2' ) ) { |
|
| 60 | - require_once LSX_TEAM_PATH . 'vendor/CMB2/init.php'; |
|
| 61 | - } |
|
| 62 | - } |
|
| 54 | + /** |
|
| 55 | + * Loads the plugin functions. |
|
| 56 | + */ |
|
| 57 | + private function load_vendors() { |
|
| 58 | + // Configure custom fields. |
|
| 59 | + if ( ! class_exists( 'CMB2' ) ) { |
|
| 60 | + require_once LSX_TEAM_PATH . 'vendor/CMB2/init.php'; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Returns the post types currently active |
|
| 66 | - * |
|
| 67 | - * @return void |
|
| 68 | - */ |
|
| 69 | - public function get_post_types() { |
|
| 70 | - $post_types = apply_filters( 'lsx_team_post_types', isset( $this->post_types ) ); |
|
| 71 | - foreach ( $post_types as $index => $post_type ) { |
|
| 72 | - $is_disabled = \cmb2_get_option( 'lsx_team_options', $post_type . '_disabled', false ); |
|
| 73 | - if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
|
| 74 | - unset( $post_types[ $index ] ); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - return $post_types; |
|
| 78 | - } |
|
| 64 | + /** |
|
| 65 | + * Returns the post types currently active |
|
| 66 | + * |
|
| 67 | + * @return void |
|
| 68 | + */ |
|
| 69 | + public function get_post_types() { |
|
| 70 | + $post_types = apply_filters( 'lsx_team_post_types', isset( $this->post_types ) ); |
|
| 71 | + foreach ( $post_types as $index => $post_type ) { |
|
| 72 | + $is_disabled = \cmb2_get_option( 'lsx_team_options', $post_type . '_disabled', false ); |
|
| 73 | + if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
|
| 74 | + unset( $post_types[ $index ] ); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + return $post_types; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Includes the Post Search Ajax if it is there. |
|
| 82 | - * |
|
| 83 | - * @return void |
|
| 84 | - */ |
|
| 85 | - public function cmb2_post_search_ajax() { |
|
| 86 | - require_once LSX_TEAM_PATH . 'vendor/lsx-field-post-search-ajax/cmb-field-post-search-ajax.php'; |
|
| 87 | - if ( method_exists( 'MAG_CMB2_Field_Post_Search_Ajax', 'get_instance' ) ) { |
|
| 88 | - $this->cmb2_post_search_ajax = \MAG_CMB2_Field_Post_Search_Ajax::get_instance(); |
|
| 89 | - } |
|
| 90 | - } |
|
| 80 | + /** |
|
| 81 | + * Includes the Post Search Ajax if it is there. |
|
| 82 | + * |
|
| 83 | + * @return void |
|
| 84 | + */ |
|
| 85 | + public function cmb2_post_search_ajax() { |
|
| 86 | + require_once LSX_TEAM_PATH . 'vendor/lsx-field-post-search-ajax/cmb-field-post-search-ajax.php'; |
|
| 87 | + if ( method_exists( 'MAG_CMB2_Field_Post_Search_Ajax', 'get_instance' ) ) { |
|
| 88 | + $this->cmb2_post_search_ajax = \MAG_CMB2_Field_Post_Search_Ajax::get_instance(); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | } |
| 92 | 92 | LSX_Team_Core::get_instance(); |