This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function replace_thumbnail( $id, $object_id, $meta_key ) { | |
| if ( '_thumbnail_id' === $meta_key && 'post' === get_post_type( $object_id ) ) { | |
| remove_filter( 'get_post_metadata', __FUNCTION__ ); | |
| $default_id_img = 91; | |
| $id = has_post_thumbnail( $object_id ) ? $id : $default_id_img; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function wpcf7_remove_assets() { | |
| add_filter( 'wpcf7_load_js', '__return_false' ); | |
| add_filter( 'wpcf7_load_css', '__return_false' ); | |
| } | |
| add_action( 'wpcf7_init', 'wpcf7_remove_assets' ); | |
| function wpcf7_add_assets( $atts ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $data = wp_remote_get( 'https://www.tvasites.com/cmswebparts/insite3/api/exporttowordpress.aspx' ); | |
| $data = wp_remote_retrieve_body( $data ); | |
| $output = []; | |
| if ( preg_match_all( '/{([^}]*)}/', $data, $matches ) ) { | |
| foreach ( $matches[1] as $item ) { | |
| $lines = preg_split( '/\\r\\n?|\\n/', $item, null, PREG_SPLIT_NO_EMPTY ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function cr_get_data_crypto( $type = '', $symbol = '' ) { | |
| $symbol = $symbol ? $symbol : cr_get_crypto_symbol(); | |
| $cache_key = $symbol . '-coinsnapshot'; | |
| $data = wp_cache_get( $cache_key ); | |
| if ( $symbol && false === $data ) { | |
| $file = CRYPT_REVIEWS_PATH . "data-import/coins/$symbol-coinsnapshot.json"; | |
| $data = is_file( $file ) ? json_decode( file_get_contents( $file ) ) : []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'rest_prepare_post', 'add_rest_post_view_counter', 10, 3 ); | |
| /** | |
| * @param WP_REST_Response $response The response object. | |
| * @param WP_Post $post Post object. | |
| * @param WP_REST_Request $request Request object. | |
| * | |
| * @return mixed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Оставляет указанные группы полей ACF на странице указанных терминов в админке, а на остальных удаляет. | |
| * | |
| * @param array $field_groups | |
| * | |
| * @return array | |
| */ | |
| function acf_filter_field_groups_in_term( $field_groups ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'init', function () { | |
| if ( ! isset( $_GET['acf-convert'] ) ) { | |
| return; | |
| } | |
| $posts = get_posts( [ | |
| 'post_type' => 'event', | |
| 'numberposts' => - 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Вариант с Рубриками | |
| add_action( 'pre_handle_404', 'fix_fake_category_page' ); | |
| function fix_fake_category_page( $false ) { | |
| global $wp_query; | |
| if ( is_archive() && get_query_var('category_name') === '0' ) { | |
| // if ( is_archive() && ! term_exists( get_query_var( 'category_name' ) ) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Регистрируем свои колонки (столбцы). Обязательно. | |
| add_filter( 'manage_post_posts_columns', function ( $columns ) { | |
| $my_columns = [ | |
| 'id' => 'ID', | |
| 'image' => 'Миниатюра', | |
| ]; | |
| return array_slice( $columns, 0, 1 ) + $my_columns + $columns; |