wordpress

Add logout link to WordPress admin dashboard left sidebar menu

痴心易碎 提交于 2021-02-18 19:40:51
问题 I want to add logout link(button) in the left side of my wordpress admin dashboard. Like on the picture.. How can I do it? 回答1: UPDATED You can achive this using admin_init action hook and global $menu . Here is this code: add_action('admin_init', 'text_domain_logout_link'); function text_domain_logout_link() { global $menu; $menu[9999] = array(__('Logout'), 'manage_options', wp_logout_url()); } This code goes in function.php file of your active child theme (or theme) or also in any plugin

Add logout link to WordPress admin dashboard left sidebar menu

北城余情 提交于 2021-02-18 19:38:51
问题 I want to add logout link(button) in the left side of my wordpress admin dashboard. Like on the picture.. How can I do it? 回答1: UPDATED You can achive this using admin_init action hook and global $menu . Here is this code: add_action('admin_init', 'text_domain_logout_link'); function text_domain_logout_link() { global $menu; $menu[9999] = array(__('Logout'), 'manage_options', wp_logout_url()); } This code goes in function.php file of your active child theme (or theme) or also in any plugin

Set cart shipping total amount issue after Woocommerce update

无人久伴 提交于 2021-02-18 19:33:02
问题 After the update my custom shipping amount rules are not working. Before the update I was using the following code to update shipping amount. add_action('woocommerce_calculate_totals', 'mysite_box_discount'); function mysite_box_discount($cart ) { $cart->shipping_total=100; return $cart; } After the update the structure of $cart array has changed and the above code has stopped working. Now the data coming in form of a protected array. I found that $cart->get_shipping_total(); can fetch me

Hook a section into WooCommerce Emails with customer ID

 ̄綄美尐妖づ 提交于 2021-02-18 19:30:20
问题 I am keen to hook a section into the WooCommerce emails with the customer number (which is the Wordpress user ID). If I insert the following code directly into the email template file echo $order->user_id; It works just fine, but if I try and hook it in, nothing is returned - except the word 'Hooked' which shows my hook is correct. add_action( 'woocommerce_email_after_order_table', 'lnz_hook_content', 1); function lnz_hook_content() { echo 'hooked'; // Test Purposes only echo $order->user_id;

Apache 2.4 + FPM + Wordpress Multisite: URL Rewrite not working in admin

那年仲夏 提交于 2021-02-18 19:19:52
问题 I just moved a Wordpress multi-site from a Apache 2.4 Prefork + mod_php to a new server with Apache 2.4 Event + php-fpm. The site is working well on the frontend and it is a lot faster then before due to the CGI, but... the Wordpress administration panel is working just for the main site (and network administration). The admin area for the second site is no more working, but the frontend is working great. Examples http://www.example.com/en/wp-admin/ => works http://www.example.com/en/wp-admin

Redirect to custom URL after user clicks 'Proceed to checkout' at the cart page (wordpress)

喜你入骨 提交于 2021-02-18 18:50:42
问题 When user clicks 'Proceed to checkout' at the cart page, I would like to send him to custom URL. I used this filter in functions.php add_filter('woocommerce_get_checkout_url', 'dj_redirect_checkout'); function dj_redirect_checkout($url) { global $woocommerce; $checkout_url = 'http://my-custom-url.com'; return $checkout_url; } However, in this case this filter is triggered on the checkout page as well and I would like to trigger it on the Cart page and after the click 'Proceed to checkout'

Redirect to custom URL after user clicks 'Proceed to checkout' at the cart page (wordpress)

南笙酒味 提交于 2021-02-18 18:50:31
问题 When user clicks 'Proceed to checkout' at the cart page, I would like to send him to custom URL. I used this filter in functions.php add_filter('woocommerce_get_checkout_url', 'dj_redirect_checkout'); function dj_redirect_checkout($url) { global $woocommerce; $checkout_url = 'http://my-custom-url.com'; return $checkout_url; } However, in this case this filter is triggered on the checkout page as well and I would like to trigger it on the Cart page and after the click 'Proceed to checkout'

Display specific product attributes under product title in Woocommerce archive pages

倖福魔咒の 提交于 2021-02-18 18:19:33
问题 In woocommerce, I would like to show some product attributes on shop page under the product titles. This product attributes are "year", "model" and "oil". This is what I have for now: add_action('woocommerce_shop_loop_item_title', 'wh_insertAfterShopProductTitle', 15); function wh_insertAfterShopProductTitle() { global $product; $abv = $product->get_attribute('pa_year'); if (empty($abv)) return; echo __($abv, 'woocommerce'); } Any help is appreciated. 回答1: To display "year", "model" and "oil"

Display specific product attributes under product title in Woocommerce archive pages

≯℡__Kan透↙ 提交于 2021-02-18 18:18:48
问题 In woocommerce, I would like to show some product attributes on shop page under the product titles. This product attributes are "year", "model" and "oil". This is what I have for now: add_action('woocommerce_shop_loop_item_title', 'wh_insertAfterShopProductTitle', 15); function wh_insertAfterShopProductTitle() { global $product; $abv = $product->get_attribute('pa_year'); if (empty($abv)) return; echo __($abv, 'woocommerce'); } Any help is appreciated. 回答1: To display "year", "model" and "oil"

Woocommerce custom coupon type with custom discount always return 0;

ε祈祈猫儿з 提交于 2021-02-18 18:13:10
问题 what I am trying to do is creating custom coupon type with custom programmatically discount in woocommerce using hooks. This what my code looks like //add new coupon type called "custom_discount" function custom_discount_type( $discount_types ) { $discount_types['custom_discount'] =__( 'custom discount', 'woocommerce' ); return $discount_types; } // add the hooks add_filter( 'woocommerce_coupon_discount_types', 'custom_discount_type',10, 1); //function to get coupon amount for "custom