Changeset 3062279
- Timestamp:
- 04/01/2024 09:47:21 PM (2 years ago)
- Location:
- lct-useful-shortcodes-functions/trunk
- Files:
-
- 9 edited
-
code/admin/old/display/OLD_options.php (modified) (2 diffs)
-
code/admin/post_types.php (modified) (3 diffs)
-
code/admin/taxonomies.php (modified) (4 diffs)
-
code/api/_helpers.php (modified) (1 diff)
-
code/api/class.php (modified) (3 diffs)
-
code/plugins/Avada/_loaded.php (modified) (2 diffs)
-
code/plugins/acf/_shortcodes.php (modified) (2 diffs)
-
lct-useful-shortcodes-functions.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lct-useful-shortcodes-functions/trunk/code/admin/old/display/OLD_options.php
r2894473 r3062279 443 443 * 444 444 * @return array 445 * @verified 2024.04.01 445 446 */ 446 447 function lct_select_options_lct_standard_year( … … 451 452 ) { 452 453 $time = current_time( 'timestamp', 1 ); 453 $v['date_start'] ? $start = $v['date_start'] : $start = date( "Y", $time ) - 3;454 $v['date_end'] ? $end = $v['date_end'] : $end = date( "Y", $time ) + 3;454 $v['date_start'] ? $start = $v['date_start'] : $start = 2014; 455 $v['date_end'] ? $end = $v['date_end'] : $end = date( "Y", $time ) + 1; 455 456 456 457 $select_options = []; -
lct-useful-shortcodes-functions/trunk/code/admin/post_types.php
r2894473 r3062279 66 66 67 67 68 /**69 * filters70 */71 add_filter( 'register_post_type_args', [ $this, 'prevent_bad_permalinks' ], 10, 2 );72 73 74 68 if ( lct_frontend() ) { 75 69 add_filter( 'wp_get_nav_menu_items', [ $this, 'archive_menu_filter' ], 10, 3 ); … … 77 71 78 72 79 //if ( lct_wp_admin_all() ) {}80 81 82 73 if ( lct_wp_admin_non_ajax() ) { 83 74 add_action( 'admin_head-nav-menus.php', [ $this, 'inject_archives_menu_meta_box' ] ); 84 75 } 85 86 87 //if ( lct_ajax_only() ) {}88 76 } 89 77 … … 174 162 $this->create_testimony(); 175 163 } 176 }177 178 179 /**180 * Prevent bad permalink issues181 *182 * @param $args183 * @param $post_type184 *185 * @return mixed186 * @since 2017.81187 * @verified 2017.09.25188 */189 function prevent_bad_permalinks( $args, $post_type )190 {191 if (192 ( $permalink = get_option( 'permalink_structure' ) )193 && strpos( $permalink, '/blog/' ) === 0194 && ( $post_types = apply_filters( 'lct/post_types/prevent_bad_permalinks', [], $post_type, $args ) )195 && in_array( $post_type, $post_types )196 && (197 ! isset( $args['rewrite']['with_front'] )198 || $args['rewrite']['with_front'] !== false199 )200 ) {201 $args['rewrite']['with_front'] = false;202 }203 204 205 return $args;206 164 } 207 165 -
lct-useful-shortcodes-functions/trunk/code/admin/taxonomies.php
r3030238 r3062279 246 246 * @return array 247 247 * @since 0.0 248 * @verified 202 1.04.30248 * @verified 2024.03.13 249 249 */ 250 250 function default_args( $custom_args = [], $slug = null, $labels = null ) … … 265 265 'show_admin_column' => false, 266 266 'description' => '', 267 'hierarchical' => true,267 'hierarchical' => false, 268 268 //'update_count_callback' => null, 269 269 //'query_var' => true, … … 303 303 * @unused param $class 304 304 * @since 0.0 305 * @verified 2024.0 1.10305 * @verified 2024.03.13 306 306 */ 307 307 function register_post_status( $taxonomy, $post_types ) … … 323 323 if ( ! ( $terms_to_register = lct_get_option( $this->cache_key( $taxonomy ), [] ) ) ) { 324 324 $tax_args = [ 325 'taxonomy' => $taxonomy,326 'hide_empty' => false,327 'hierarchical' => true,328 get_cnst( 'a_c_f_tax_disable' )=> true,325 'taxonomy' => $taxonomy, 326 'hide_empty' => false, 327 'hierarchical' => true, 328 'lct:::tax_disable' => true, 329 329 ]; 330 330 $terms = get_terms( $tax_args ); -
lct-useful-shortcodes-functions/trunk/code/api/_helpers.php
r2991310 r3062279 2793 2793 2794 2794 return $r; 2795 }2796 2797 2798 /**2799 * We need to handle the counting of status taxonomies2800 * Will update term count based on object types of the current taxonomy.2801 *2802 * @based_on _update_post_term_count()2803 *2804 * @param array $terms List of Term taxonomy IDs.2805 * @param object $taxonomy Current taxonomy object of terms.2806 *2807 * @global wpdb $wpdb WordPress database abstraction object.2808 * @since 2017.962809 * @verified 2020.06.132810 * @noinspection PhpMissingParamTypeInspection2811 */2812 function lct_update_status_taxonomy_term_count( $terms, $taxonomy )2813 {2814 global $wpdb;2815 2816 $object_types = (array) $taxonomy->object_type;2817 2818 foreach ( $object_types as $k => $object_type ) {2819 if ( strpos( $object_type, ':' ) !== false ) {2820 $object_types[ $k ] = explode( ':', $object_type );2821 }2822 }2823 2824 $object_types = array_unique( $object_types );2825 2826 2827 if ( false !== ( $check_attachments = array_search( 'attachment', $object_types ) ) ) {2828 unset( $object_types[ $check_attachments ] );2829 $check_attachments = true;2830 }2831 2832 2833 if ( $object_types ) {2834 $object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) );2835 }2836 2837 2838 foreach ( $terms as $term ) {2839 $count = 0;2840 2841 2842 // Attachments can be 'inherit' status, we need to base count off the parent's status if so.2843 if ( $check_attachments ) {2844 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) );2845 }2846 2847 if ( $object_types ) {2848 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_type IN ('" . implode( "', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );2849 }2850 2851 2852 /**2853 * This action is documented in wp-includes/taxonomy.php2854 *2855 * @date 0.02856 * @since 0.02857 * @verified 2021.08.272858 */2859 do_action( 'edit_term_taxonomy', $term, $taxonomy->name );2860 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), [ 'term_taxonomy_id' => $term ] );2861 2862 2863 /**2864 * This action is documented in wp-includes/taxonomy.php2865 *2866 * @date 0.02867 * @since 0.02868 * @verified 2021.08.272869 */2870 do_action( 'edited_term_taxonomy', $term, $taxonomy->name );2871 }2872 2795 } 2873 2796 -
lct-useful-shortcodes-functions/trunk/code/api/class.php
r2894473 r3062279 226 226 add_action( 'acf/include_fields', [ $this, 'acf_actions_n_filters_pre' ], 9999 ); 227 227 228 228 229 add_action( 'acf/init', [ $this, 'acf_actions_n_filters' ], 999 ); 229 230 … … 234 235 add_filter( 'acf/settings/autoload', '__return_true' ); 235 236 236 //I disabled in 2019.3 to test if this is really needed anymore. I think it is too expensive now.237 //add_filter( 'acf/get_fields', [ $this, 'acf_get_fields' ], 10, 2 );238 237 239 238 add_filter( 'register_post_type_args', [ $this, 'acf_post_type_args' ], 10, 2 ); … … 596 595 597 596 /** 598 * Saves us from running unnecessary queries for conditionally hidden sub_fields599 *600 * @param $fields601 * @param $parent602 *603 * @return mixed604 * @since LCT 2017.42605 * @verified 2018.10.08606 */607 function acf_get_fields( $fields, $parent )608 {609 if (610 ! empty( $fields )611 && ! empty( $parent['type'] )612 && ! empty( $parent['name'] )613 && $parent['type'] === 'repeater'614 && acf_get_setting( 'autoload' )615 && ! lct_get_setting( 'acf_is_options_page' )616 && ! lct_get_setting( 'single_version_db_updates' )617 ) {618 $all_options = wp_load_alloptions();619 $check = 'options_' . $parent['name'];620 621 622 if ( array_key_exists( $check, $all_options ) ) {623 if ( $all_options[ $check ] ) {624 for ( $i = 0; $i <= $all_options[ $check ]; $i ++ ) {625 foreach ( $fields as $field ) {626 $check_nest_1 = 'options_' . $parent['name'] . '_' . $i . '_' . $field['name'];627 628 629 if ( ! array_key_exists( $check_nest_1, $all_options ) ) {630 add_filter( 'pre_option_' . $check_nest_1, '__return_null' );631 }632 }633 }634 }635 } else {636 add_filter( 'pre_option_' . $check, '__return_null' );637 }638 }639 640 641 return $fields;642 }643 644 645 /**646 597 * Allow revisions for ACF fields 647 598 * -
lct-useful-shortcodes-functions/trunk/code/plugins/Avada/_loaded.php
r2894473 r3062279 59 59 add_action( 'widgets_init', [ $this, 'disable_blog_sidebar' ], 11 ); 60 60 61 61 62 add_action( 'after_setup_theme', [ $this, 'remove_image_size' ], 11 ); 62 63 64 63 65 add_action( 'after_setup_theme', [ $this, 'remove_theme_supports' ], 11 ); 64 66 67 65 68 add_action( 'plugins_loaded', [ $this, 'disable_fusion_builder_activate' ] ); 66 69 70 67 71 add_action( 'init', [ $this, 'remove_post_types' ], 9 ); 68 69 70 /**71 * filters72 */73 add_filter( 'lct/post_types/prevent_bad_permalinks', [ $this, 'prevent_bad_permalinks' ], 10, 3 );74 75 76 //if ( lct_frontend() ) {}77 78 79 //if ( lct_wp_admin_all() ) {}80 72 81 73 82 74 if ( lct_wp_admin_non_ajax() ) { 83 75 add_action( 'lct/op_main/init', [ $this, 'add_op_main_Avada' ] ); 76 77 78 add_action( 'plugins_loaded', [ $this, 'disable_admin_hooks_by_removal' ] ); 79 84 80 85 81 if ( ! empty( $_GET['post'] ) ) { 86 82 add_filter( 'gettext', [ $this, 'avada_admin_language' ], 99, 3 ); 87 83 } 88 89 90 add_action( 'plugins_loaded', [ $this, 'disable_admin_hooks_by_removal' ] ); 91 } 92 93 94 //if ( lct_ajax_only() ) {} 84 } 95 85 } 96 86 … … 213 203 214 204 /** 215 * Add Avada post_types to the bad permalink protection list216 *217 * @param $post_types218 *219 * @unused param $post_type220 * @unused param $args221 * @return array222 * @since 2017.81223 * @verified 2017.09.25224 */225 function prevent_bad_permalinks( $post_types )226 {227 $post_types[] = 'avada_portfolio';228 $post_types[] = 'avada_faq';229 $post_types[] = 'themefusion_elastic';230 231 232 return $post_types;233 }234 235 236 /**237 205 * Replace Some language with our own 238 206 * -
lct-useful-shortcodes-functions/trunk/code/plugins/acf/_shortcodes.php
r2948966 r3062279 2049 2049 * @return string 2050 2050 * @since 2017.42 2051 * @verified 202 2.08.242051 * @verified 2024.03.22 2052 2052 */ 2053 2053 function acf( $a ) … … 2109 2109 2110 2110 case 'user': 2111 $aa = $a; 2112 $aa['format_value'] = false; 2113 2114 2115 $shortcode = acf_shortcode( $aa ); 2111 $shortcode = get_field_object( $a['field'], $a['post_id'], false ); 2116 2112 2117 2113 2118 2114 if ( 2119 $shortcode2120 && $a['format_value']2115 ! empty( $shortcode['value'] ) 2116 && ( $user_obj = get_userdata( $shortcode['value'] ) ) 2121 2117 ) { 2122 $shortcode = acf_format_value( $shortcode, $a['post_id'], $field ); 2123 2124 2125 if ( is_array( $shortcode ) ) { 2126 if ( $shortcode['display_name'] ) { 2127 $shortcode = $shortcode['display_name']; 2128 } else { 2129 $shortcode = $shortcode['user_firstname'] . ' ' . $shortcode['user_lastname']; 2130 } 2131 } 2118 $shortcode = $user_obj->display_name; 2132 2119 } 2133 2120 break; -
lct-useful-shortcodes-functions/trunk/lct-useful-shortcodes-functions.php
r3050689 r3062279 4 4 * Plugin URI: https://www.simplesmithmedia.com 5 5 * Description: Shortcodes & Functions that will help make your life easier. 6 * Version: 2024.0 26 * Version: 2024.03 7 7 * Author: SimpleSmithMedia 8 8 * Author URI: https://www.simplesmithmedia.com -
lct-useful-shortcodes-functions/trunk/readme.txt
r3050689 r3062279 33 33 34 34 == Changelog == 35 = 2024.03 = 36 *Release Date - 01 April 2024* 37 38 * Removed: 39 * add_filter( 'register_post_type_args', [ $this, 'prevent_bad_permalinks' ], 10, 2 ); 40 * lct_update_status_taxonomy_term_count() 41 * add_filter( 'acf/get_fields', [ $this, 'acf_get_fields' ], 10, 2 ); 42 * add_filter( 'lct/post_types/prevent_bad_permalinks', [ $this, 'prevent_bad_permalinks' ], 10, 3 ); 43 35 44 = 2024.02 = 36 45 *Release Date - 13 March 2024*
Note: See TracChangeset
for help on using the changeset viewer.