This file contains 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 | |
/** | |
* Plugin Name: Преобразуент контент записи в plain text | |
*/ | |
add_action( 'admin_menu', function () { | |
add_management_page( | |
'Форматирование записи', | |
'Форматирование записи', | |
'manage_options', |
This file contains 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 | |
/** | |
* Ищет посты, у которых в заголовке содержится указанная строка. | |
* | |
* @param string $title | |
* | |
* @return array | |
*/ | |
function get_posts_relevant_title( $title ) { | |
global $wpdb; |
This file contains 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 | |
/** | |
* Статья https://wp-kama.ru/plugin/acf/dobavlenie-polej-k-opredelennoj-rubrike | |
* Видео https://youtu.be/mHJHnyPLf0M | |
*/ | |
if ( is_admin() && ! wp_doing_ajax() ) { | |
add_filter( 'acf/location/rule_types', 'acf_location_rules_types', 999 ); |
This file contains 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( 'acf/location/rule_match/post_category', 'acf_location_rules_match_category', 10, 3 ); | |
function acf_location_rules_match_category( $match, $rule, $options ) { | |
$parent_slug = str_replace( 'category:', '', $rule['value'] ); | |
$parent_term = get_category_by_slug( $parent_slug ); | |
// Не нашлось указанной рубрики в условии по отображению | |
if ( ! $parent_term ) { |
This file contains 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( 'the_posts', 'prefix_the_posts', 10, 2 ); | |
/** | |
* @param array $posts | |
* @param WP_Query $wp_query | |
* | |
* @return array | |
*/ |
This file contains 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 | |
/** | |
* Загружает изображение в медиабиблиотеку по переданному url. | |
* | |
* @param string $url | |
* @param int $post_id | |
* | |
* @return int|WP_Error | |
*/ |
This file contains 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; |