Help me with my first very basic plugin

I have already answered this question stackoverflow, but adding the answer here as well: Looking on the code it does not seem like the WordPress way of doing this kind of thing. First you need to include your ajax-process.php in the plugins main file e.g: require_once plugin_dir_path(__FILE__) . ‘/ajax-process.php’; Second, you need to register your … Read more

Pull GET parameter from URL in functions.php

Contact Form 7 provides a recipe for Validation as a Filter which looks very much like what you are trying to do. Adapting their example to your code, I believe the following should work for you: add_filter( ‘wpcf7_validate_text*’, ‘custom_password_reset_validation_filter’, 10, 2 ); function custom_password_reset_validation_filter( $result, $tag ) { if (‘token’==$tag->name){ $token = isset($_POST[‘token’]) ? $_POST[‘token’] … Read more

MySQL update text field with ‘

Apparently someplace in the wp_list_table, or maybe someplace else, the escape character \ was inserted before any ‘ . I was able to solve this by adding this line of code just before the $wpdb->update statement. $item[‘RecordedSubdivision’] = str_replace(“\'”, “‘”,$item[‘RecordedSubdivision’]);

How do I modify the with wp_nav_menu()

Welcome to WPSO. You need to modify the Walker_Nav_Menu Class. That class is responsible for rendering the HTML menu output in first place. The theme you are using is calling the WordPress menu class, which will then output your menu. As alexwc_ mentioned the alt attribute is for images, not for anchor tags. So in … Read more

Cannot get custom javascript to execute on page

Try this. add_action ( ‘wp_head’, ‘custom_script_hook’); function custom_script_hook() { ?> <script type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js”></script> <?php $output=”<script> jQuery(document).ready(() => { $(“div#tm-extra-product-options”).click(() => { console.log(“it working!”) }); }); </script>”; echo $output; }

Global variables and re-use

In general programming, globals are bad practice: You can’t easily look at the use of a global in one place and see all the other uses, e.g. where it was set or will be read later. You have many places to change the use of that variable if e.g. the use or format of it … Read more