Force SSL using FORCE_SSL_ADMIN

If you are using docker-compose and the WORDPRESS_EXTRA_CONFIG as I was, when I stumbled across that error, the solution would be to use double-dollar-sign notation as described in a corresponding issue in the docker-compose repo on GitHub. This additional environment variable is described in the “How to use this image” of the official image documentation … Read more

Asking popup for delete post in WordPress [closed]

Yes, it’s possible. You have to create a JavaScript File and enqueue this file for admin use. This hook is to add files for the backend: add_action( ‘admin_enqueue_scripts’, ‘your_function_name’ ); This hook is to add files for the frontend: add_action( ‘wp_enqueue_scripts’, ‘your_function_name’ ); So we need to use the admin_enqueue_scripts hook and create our function: … Read more

Put CSS inside a PHP file and include it the right way

You might try conditional classes instead. In your regular “style.css” file you would include both classes: .theme-header-title.green { color:green; } .theme-header-title.blue { color:blue; } (Tip 1: avoid !important, just use a more specific style if needed – for example, h1.theme-header-title.green.) Then in your HTML, which is likely in your “header.php” file, you’d use the Customizer … Read more

Have CSS Class Added with `is_page()` WP function

Bitwise operators expect conditionals on either side of them to evaluate to either TRUE or FALSE. If FALSE it checks the next conditional until it finds a TRUE or all conditionals have been checked. Also, the is_page() function doesn’t allow parameters to be passed in on a bitwise basis. So simply change your code to … Read more

Interrupting $html.= ‘ for IF statement

This is more general PHP than anything WordPress specific. String concatenation occurs whenever you combining two stings with the . operator. During string concatenation some basic PHP keywords will not apply and you’ll need to use the shorthand equivalent instead. In this case you can use the ternary (conditional) operator $html.= ‘<span class=”cat”>In ‘. ( … Read more

When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?

You can determine the calling files using debug_backtrace in PHP, which will give you the backtrace of the functions called and the file called from. WP core provides wp_debug_backtrace_summary, which makes doing things like this easier. Using the condition stated in your question of being called from my_file.php you could do something like this: add_filter( … Read more

Custom PHP page form data is not appearing as a wp-theme page template

The approach I usually take is to check to see if your submit input exists and construct the page based on that condition. For example, if your submit/send button was constructed similar to this: <input class=”cta” type=”submit” name=”submit_all” value=”Send message”> Then your condition check would look like: if ( isset( $_POST[‘submit_all’] ) ) { // … Read more

OrderItem get_total() returns lower value than $order_item->get_product()->get_price() * quantity

The problem seems to be related to missing tax or (and) to applied coupon discount. The WC_Order_Item_Product method get_total() is the discounted line item total without taxes. In this case when a coupon is used, the discount is applied to the item depending of the coupon type and restrictions. The WC_Order_Item_Product method get_subtotal() is the … Read more

Show Different Header on a Specific Post ID

In your header.php file, you can test which page is loading and modify the markup based on this condition. For your example, the is_page() function seems ideal. <div style =”float: right; margin-top: 10px;”> <p class=”headersample3″> <?php if ( is_page( ‘###’ ) ) { ?> <a href=”https://wordpress.stackexchange.com/questions/359723/tel:555-555-5555″>555-555-5555</a> <?php } else { ?> <a href=”tel:888-888-8888″>888-888-8888</a> <?php } … Read more