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
/** | |
* WooCommerce: Показ ID категорий | |
*/ | |
// Добавляем столбец ID | |
function woo_cat_id_columns($columns){ | |
$columns = array('tag_ID' => __('ID', 'rw-addon'))+ $columns; | |
return $columns; | |
} | |
add_filter("manage_edit-product_cat_columns", "woo_cat_id_columns"); | |
// Отображаем столбец 'tag_ID' |
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
console.log('script ready'); | |
(function($) { | |
var MyYoastPlugin = function() | |
{ | |
YoastSEO.app.registerPlugin('myYoastPlugin', {status: 'loading'}); | |
this.getData(); |
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 for post duplication. Dups appear as drafts. User is redirected to the edit screen | |
*/ | |
function rd_duplicate_post_as_draft(){ | |
global $wpdb; | |
if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) { | |
wp_die('No post to duplicate has been supplied!'); | |
} |
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 | |
/* Abstract Factory in PHP */ | |
interface FactoryOS | |
{ | |
public static function createMenu() : Menu; | |
public static function createButton() : Button; | |
} |
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: Your Shipping plugin | |
Plugin URI: https://woocommerce.com/ | |
Description: Your shipping method plugin | |
Version: 1.0.0 | |
Author: WooThemes | |
Author URI: https://woocommerce.com/ | |
*/ |
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
add_filter('iiko_checkout_fields', function ($fields){ | |
$fields['delivery_terminal']['default'] = ''; | |
$fields['delivery_terminal']['options'] = [''=>''] + $fields['delivery_terminal']['options']; | |
return $fields; | |
}, 10, 1 ); | |
add_action( 'woocommerce_after_checkout_validation', function ($data, \WP_Error $errors) { | |
if(isset($data['billing_delivery_terminal']) && empty($data['billing_delivery_terminal'])){ | |
$errors->add('iiko_terminal', __('Please select the terminal', 'iiko')); | |
} |
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
add_filter('wc_iiko_product', function (ProductArg $data, \iiko\classes\Product $iiko_product ){ | |
if(!empty($iiko_product->tags) && false !== strpos($iiko_product->tags, 'Избранные' )) { | |
$data->featured = true; | |
} | |
return $data; | |
}, 10, 2 ); |
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 | |
// WP AJAX example | |
class WP_AJAX_Example{ | |
/** | |
* Add WP actions. Must be called only once. | |
* @return void | |
*/ | |
public function add_actions(){ |
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
/** | |
* WordPress Autoload classes. | |
*/ | |
spl_autoload_register( function ( $full_class_name ) { //phpcs:ignore PEAR.Functions.FunctionCallSignature | |
if ( strpos( $full_class_name, __NAMESPACE__ ) !== 0 ) { // . '\Core' | |
return; // Not in the plugin namespace, don't check. | |
} | |
$full_class_name = strtolower( str_replace( '_', '-', $full_class_name ) ); | |
$class_parts = explode( '\\', $full_class_name ); | |
unset( $class_parts[0] ); // Unset the __NAMESPACE__. |
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
add_action('woocommerce_before_thankyou', function ($wc_order_id){ | |
$wc_order = wc_get_order($wc_order_id); | |
if (empty($wc_order) || $wc_order->has_status('failed')) { | |
return; | |
} | |
$wc_order->update_meta_data('deliveryDurationInMinutes', ''); | |
$wc_order->save_meta_data(); | |
}, 5); |
OlderNewer