add_filter( 'w4pl/get_shortcodes', 'custom_product_shortcodes', 20 );
function custom_product_shortcodes( $shortcodes ) {
$shortcodes['product_price'] = [
'group' => 'Post',
'callback' => 'custom_wc_product_price',
'desc' => '<strong>'. __('Output', 'text-domain') .'</strong>: product price'
];
$shortcodes['product_short_description'] = [
'group' => 'Post',
This file contains hidden or 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 | |
| add_action( 'the_post', 'inject_ad_in_loop', 10, 2 ); | |
| function inject_ad_in_loop( $post, $wp_query ) { | |
| // gather the type of post_types are being queried | |
| $post_types = $wp_query->get('post_type'); | |
| if ( ! $post_types ) { | |
| $post_types = [ 'post' ]; | |
| } elseif ( ! is_array( $post_types ) ) { | |
| $post_types = [ $post_types ]; |
This file contains hidden or 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
| function disable_self_site_pingback( &$links ) { | |
| foreach ( $links as $l => $link ) { | |
| if ( 0 === strpos( $link, home_url( '/' ) ) ) { | |
| unset( $links[ $l ] ); | |
| } | |
| } | |
| } | |
| add_action( 'pre_ping', 'disable_self_site_pingback' ); | |
| #reference - https://core.trac.wordpress.org/browser/tags/5.3/src/wp-includes/comment.php#L2852 |
/**
* Plugin Name: MyPlugin
*/
register_activation_hook(__FILE__, 'myplugin_activated');
function myplugin_activated()
{/*
* register_deactivation_hook function is triggered when a plugin is deactivated.
* register_deactivation_hook(__FILE__, 'myplugin_deactivated');
*/
function myplugin_deactivated()
{
$to_email = get_option('admin_email');
$subject = 'MyPlugin has been deactivated';/*
* register_activation_hook function is triggered when this plugin is activated
* from the WP admin -> Plugins page.
*/
register_activation_hook(__FILE__, 'myplugin_activated');
function myplugin_activated()
{
// Email address where mail will be sentadd_shortcode( 'popular_posts', 'popular_posts_shortcode' );
function popular_posts_shortcode($atts)
{
$html = '';
$query_args = array(
'order' => 'DESC',
'orderby' => 'comment_count',
'post_type' => 'post',
'post_status' => 'publish',add_action( 'parse_request', 'popular_page_parse_request' );
function popular_page_parse_request( $wp )
{
// custom variables will only be available on popular page
$pageslug = 'popular';
// get the actual request and parse it down
if( isset($wp->request) && strpos($wp->request, '/') )