Detecting $_GET parameters from any page + Cookie

This should work, though untested. <?php add_action(‘send_headers’, ‘affiliate_redirect’); function affiliate_redirect() { // it’s possible to use ‘if( !empty( $_GET[‘affid’]) )’ if( isset($_GET[‘affid’]) && ” != $_GET[‘affid’] ) { if( empty($_COOKIE[‘affid’]) ) setcookie(‘affid’, $_GET[‘affid’], time()+2592000, “https://wordpress.stackexchange.com/”); header(‘Location: http://mysite.com/about/’); exit; } }

Some plugins adding full server path after url (with custom wp-content folder)

Given that the js location is determined as follows: $js_location = WPSEO_URL . ‘js/wp-seo-admin-global.js’ where: WPSEO_URL = WP_PLUGIN_URL . “https://wordpress.stackexchange.com/” . <WP_SEO_PLUGIN_PATH> . “https://wordpress.stackexchange.com/” I suspect the problem lies with the derivation of <WP_SEO_PLUGIN_PATH>. This value is determined by the code in the function plugins_url() found in wp-includes\link-template.php If you debug that function, it may … Read more

Run Python Script on WordPress Website

This issue of permission denied is resolved.. Permission was already given but I have added ‘env python’ in the popen function.. Now the code is running as expected.. add_shortcode( ‘run_test_py’, ‘test_py’ ); function test_py( $attributes ) { $data = shortcode_atts( [ ‘file’ => ‘test.py’ ], $attributes ); $handle = popen(‘env python ‘. __DIR__ . “https://wordpress.stackexchange.com/” … Read more

Change My Basket text in the header of WooCommerce Artificer theme

The functions are defined in the includes folder of the artificer theme, in the theme-woocommerce.php file: // Add the cart link to the header add_action(‘woo_nav_before’, ‘artificer_header_cart_link’, 20); if ( ! function_exists( ‘artificer_header_cart_link’ ) ) { function artificer_header_cart_link() { if ( class_exists( ‘woocommerce’ ) ) { echo woocommerce_cart_link(); } } } // Add the checkout link … Read more

Manually Removing Plugins

Addition to @PatJ answer: Keep in mind that an uninstall/deactivation functions won’t trigger. So in case the plugin(s) in question leave back a lot of DB entries, you’ll have to manually clean up the DB. Another option would (maybe) be to use WP CLI and try to manually trigger any uninstall functions. This will only … Read more

Woocommerce exclude specific category products from related products [closed]

Old question, but ranks high in Google. Here’s a solution that works with today’s Woocommerce. Add this to your functions.php or custom plugin. function exclude_brands_from_related( $categories ){ // array of category id’s that should be excluded $exclude_cats = array( ‘100’, ‘101’, ‘102’); foreach( $categories as $index => $cat ){ if( in_array( $cat->term_id, $exclude_cats ) ){ … Read more

Maintaining WP_Query Relation Among CPT, Custom Taxonomy, Permalinks- CPT UI

Collaborative efforts- For http://novice.dev/books just create custom post type and check rewrite options so that it adds end points. For http://novice.dev/books/book_categories/my_story_books, create custom taxonomy related with the post type and check the options for rewrite options. http://novice.dev/books/thirty-days-and-night will be automatically when above two are done.