Where Should i write the code for wordpress ajax voting?

Use REST API endpoint instead! Lets register an endpoint at /wp-json/tomjn/v1/test, that calls tomjn_rest_test() when you hit it: add_action( ‘rest_api_init’, function () { register_rest_route( ‘tomjn/v1’, ‘/test/’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘tomjn_rest_test’ ) ); } ); Now lets add the tomjn_rest_test function: function tomjn_rest_test( $request ) { return “moomins”; } Now when we visit … Read more

How do I get the Payzone WooCommerce payment gateway plugin to show up in the settings? [closed]

As Rustom mentioned, the plugin isn’t checking if this Multisite is activated – you can add a check in for multisite, add the below in the plugin registration file, just below the existing active check functions. if(!function_exists(‘is_plugin_active_for_network’)){ require_once(ABSPATH .’/wp-admin/includes/plugin.php’); if(is_multisite() && is_plugin_active_for_network(‘woocommerce/woocommerce.php’)){//check if multisite and check /** add in the functions from inside the current … Read more

How do I create a custom permalink structure for a page template

There are different filters available to create the custom permalinks for the posts, custom posts or pages: post_type_link – for custom post types post_link – only for post_types ‘post’ page_link – for pages only ( which you are looking for ) Here is the sample code based on your query: public function custom_permalink_for_page_template( $url, $post … Read more

Using custom php file for ajax url inside plugin

Read more about AJAX in Plugins. How to use Ajax in WP: 1. Register file contain functions, event of javascript or jquery. All data will be submit by events js add_action( ‘wp_enqueue_scripts’, ‘ajax_scripts’ ); function ajax_scripts() { wp_register_script( ‘main-ajax’, get_template_directory_uri() . ‘/assets/js/main-ajax.js’, array(), ”, true ); $arr = array( ‘ajaxurl’ => admin_url(‘admin-ajax.php’) ); wp_localize_script(‘main-ajax’,’obj’,$arr ); … Read more

URL rewrite with external JSON query

You can try URL rewriting like that add_action(“wp_loaded”, function () { add_rewrite_tag(“%id%”, “([^&]+)”); add_rewrite_rule( ‘^details/[^&]+/([0-9]+)/?’, ‘index.php?id=$matches[1]&pagename=details’, ‘top’ ); }); And then flush rewrite rules cache one time in Settings -> Permalinks. With this rewriting, the identifier is no more in $_GET but you can get it with https://codex.wordpress.org/Function_Reference/get_query_var.