Skip to content

Instantly share code, notes, and snippets.

@campusboy87
campusboy87 / CF7_Notification_Shortcodes.php
Last active April 9, 2024 12:02
Allows you to use html in cf7 notifications + replaces a successfully submitted form with a success message
<?php
( new CF7_Notification_Shortcodes() )->hooks();
/**
* Allows you to use shortcodes in the CF7 form settings in the "Notifications when submitting a form" tab.
*/
class CF7_Notification_Shortcodes {
private array $shortcodes = [];
@campusboy87
campusboy87 / rank_math_seo_dropdown_filter_removal_posts_table.php
Created February 4, 2024 00:51
Removing the drop-down filter of the Rank Math SEO plugin in the table of posts
<?php
add_action( 'restrict_manage_posts', function () {
global $wp_filter;
$action = 'restrict_manage_posts';
$priority = 11;
$method = 'add_seo_filters';
if ( empty( $wp_filter[ $action ]->callbacks[ $priority ] ) ) {

API v4

базовый адрес: https://goodgame.ru/api/4/

ниже идут найденные методом тыка эндпоинты

для некоторых приведены примеры запроса,
для остальных они не известны и приведены коды ответов для запросов без параметров

@campusboy87
campusboy87 / get_repeat_field_by_pagination.php
Last active September 13, 2022 01:23
Функция для получения значения repeat acf поля с учётом пагинации.
<?php
/**
* Получает значения repeat acf поля с учётом пагинации.
*
* todo:
* 1) Кеширование
* 2) Соответствие имен вложенных полей с настройками repeat поля.
* 3) Учитывать вложенные repeat/группы поля.
*
@campusboy87
campusboy87 / breadcrumbs.html
Last active May 12, 2022 03:35
Как изменить хлебные крошки Yoast на свою вёрстку
<ul itemscope="itemscope" itemtype="https://schema.org/BreadcrumbList" class="breadcrumb">
<li itemprop="itemListElement" itemscope="itemscope" itemtype="https://schema.org/ListItem">
<a itemprop="item" href="/" class="pathway">
<span itemprop="name">Главная</span>
</a>
<span class="divider"> / </span>
<meta itemprop="position" content="1"/>
</li>
<li itemprop="itemListElement" itemscope="itemscope" itemtype="https://schema.org/ListItem">
<a itemprop="item" href="/blog/itemlist" class="pathway">
@campusboy87
campusboy87 / remote-post-with-files.php
Created April 7, 2021 15:50 — forked from kagg-design/remote-post-with-files.php
Example of how to send files to the remote server.
$boundary = str_repeat( '-', 24 ) . wp_generate_password( 16 );
$headers = array(
'content-type' => 'multipart/form-data; boundary=' . $boundary,
);
if ( ! isset( $files['path'] ) ) {
$error_message = 'Invalid arguments';
return array( $success, $error_message, $word_count, $individual_word_count );
}
@campusboy87
campusboy87 / acf_add_location_site.php
Created July 8, 2020 12:39
Добавляет условие отображения как "Главный" и "Региональный" сайта в сети сайтов WordPress
<?php
function acf_add_location_site() {
$key = 'site-location';
add_filter( 'acf/location/rule_types', function ( $choices ) use ( $key ) {
$choices['Мультисайт'][ $key ] = 'Месторасположение';
return $choices;
} );
@campusboy87
campusboy87 / CT_CF7.php
Created March 17, 2020 23:11
CF7 template
<?php
class CT_CF7 {
private $form_id = 51373;
private $form_path_tpl = '/templates/parts/form-need-help';
public function __construct() {
add_action( 'wpcf7_autop_or_not', '__return_false' );
add_action( 'wpcf7_contact_form', [ $this, 'init' ] );
}
@campusboy87
campusboy87 / set_acf_pro_license.php
Last active December 12, 2019 19:10
Automatic activation of ACF license via PHP. The code adds the key to the option in the desired format, and adds the domain to the list of trusted domains tracked in the ACF profile, so that the update is successful. The code can be used as a MU plugin, a regular plugin, or inserted into the theme code.
<?php
add_action( 'acf/init', 'set_acf_pro_license' );
function set_acf_pro_license() {
global $acf_instances;
if ( isset( $acf_instances['ACF_Admin_Updates'] ) && ! get_option( 'acf_pro_license' ) ) {
/**
* @var ACF_Admin_Updates $acf
@campusboy87
campusboy87 / wpcf7_add_title_form_to_mail_body.php
Created October 18, 2019 07:38
CF7: Добавляет заголовок формы в конец шаблона письма при отправке
<?php
add_action( 'wpcf7_before_send_mail', 'wpcf7_add_title_form_to_mail_body' );
/**
* @param WPCF7_ContactForm $contact_form
*/
function wpcf7_add_title_form_to_mail_body( $contact_form ) {
$form_title = $contact_form->title();
$form_mail = $contact_form->prop( 'mail' );