Skip to content

Instantly share code, notes, and snippets.

@eto4detak
Last active September 7, 2018 19:36
Show Gist options
  • Save eto4detak/c47226b6f3c57f8da97e6e77e8a9c1bc to your computer and use it in GitHub Desktop.
Save eto4detak/c47226b6f3c57f8da97e6e77e8a9c1bc to your computer and use it in GitHub Desktop.
wp php deprecate notice
<?php
$product->get_id()
$product->get_type()
wc_get_product_tag_list($product->get_id(), ', ', '<span class="tagged_as">' . _n( 'Tag:', 'Tags:', $tag_count, 'woocommerce' ) . ' ', '.</span>' ) ============
$product->get_tags( ', ', '<span class="tagged_as">' . _n( 'Tag:', 'Tags:', $tag_count, 'woocommerce' ) . ' ', '.</span>' )
wc_get_product_category_list($product->get_id(), ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', $cat_count, 'woocommerce' ) . ' ', '.</span>' ) ================ $product->get_categories( ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', $cat_count, 'woocommerce' ) . ' ', '.</span>' )
$product->get_gallery_image_ids() ===== $product->get_gallery_attachment_ids();
wc_get_cart_url() ===== WC()->cart->get_cart_url();
wc_get_rating_html($product->get_average_rating()) ===== $product->get_rating_html();
wc_get_product( $product_id) ===== get_product( $product_id );
wc_get_page_id( 'shop') ===== woocommerce_get_page_id( 'shop' )
wc_get_page_id( 'shop') ===== $product->get_related( $posts_per_page )
wc_get_related_products($product->get_id(), $posts_per_page) ===== $product->get_related( $posts_per_page )
$WC_Structured_Data = new WC_Structured_Data(); +===+ woocommerce_get_product_schema()
$var = $WC_Structured_Data->generate_product_data( $product ); +===+
$var->get_data(); +===+
// JS migrate
add_action( 'wp_enqueue_scripts', 'script_footer_new', 10 );
function script_footer_new($value='')
{
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', ("https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"), false, '1.12.2');
wp_enqueue_script('jquery');
}
}
// добавить поле, инфо добавления авто
function autozone_add_car_notice_admin($auto_id){
$id = (int)$auto_id;
if(!empty($id)){
$str = '';
if(!empty(get_option('notice_admin_auto'))){
$str = get_option('notice_admin_auto');
}
$str .= $id . ',';
update_option('notice_admin_auto', $str);
}
}
// предупредить админа о создании нового авто
add_action('admin_notices', function(){
global $post;
$str_ids = get_option('notice_admin_auto');
$html = '';
$url = [];
$new_ids = [];
$str_new_ids = '';
if(!empty($str_ids)){
$ids = explode(',', $str_ids);
if(!empty($ids)){
foreach( $ids as $id ){
$cur_id = (int) $id;
if(!empty($cur_id)){
$post = get_post($cur_id);
if($post->post_status === 'pending'){
$new_ids[] = $cur_id;
$html .= '<li><a href="'.get_permalink($cur_id).'">'.get_the_title().'</li></a>';
}
}
}
}
}
if(!empty($new_ids)){
foreach ($new_ids as $id) {
$str_new_ids .= $id . ',';
}
}
update_option('notice_admin_auto', $str_new_ids);
if(!empty($html)){
echo '<div class="update-nag"><p>'.esc_attr__('The post waiting for the approval of the administrator', 'autozone').'.</p><ul>'.$html.'</ul></div>';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment