How to Dynamically Load Content Into Body of Bootstrap Modal Window?

I found this answer on Stack Overflow, answer this exact question. I've modified it slightly, because I'm using a button and not an anchor: jQuery( ".modal" ).on( "show.bs.modal", function ( e ) { var target = jQuery( e.relatedTarget ).attr( "data-target" ).replace( "#", "" ); var modal_ids = [ "modal-request-estimate", "modal-schedule-appointment", "modal-rate-review" ]; if ( modal_ids.indexOf( target ) == - 1 ) { return false; } jQuery( this ).find( ".modal-body" ).load( location.href + "?modal=" + target ); } ); If then …
Category: Web

Extend Woocommerce rest api routes fails

While I'm trying to extend Woocommerce Rest-API routes with a custom one I face the following problem. I have the following class which tries to hook inside Woocommerce API class API_LOADER { public function init() { add_action( 'woocommerce_api_loaded', array( $this, 'load' ) ); } public function load() { //This method will be not called require_once plugin_dir_path( __FILE__ ).'wc-api-custom.php'; add_filter( 'woocommerce_api_classes', array( $this, 'register' ) ); } } but woocommerce_api_loaded will not trigger any callback. What I do wrong in this …
Category: Web

Add_action not calling callback function

I am currently trying to build a plugin for wordpress to build a settings page. But for some reason when I use add_action("admin_init", array(class_object, 'function_name')) it will run the add_action function but won't get to the callback. It just skips it. I have tried making a test class with 1 function in it the same way as the main class and that does work. So I am doing something different somewhere but I don't know what. here is the code. …
Category: Web

Gutenberg: How to check if a block is used in a paginated post?

There is the render_callback of the register_block_type function. In this callback, I can use add_filter('render_block', __NAMESPACE__ . '\\filter_block', 10, 2); filter_block iterates through all blocks in my post ... until the post is paginated, and the block is on page 1, but I want to check blocks on page 3 of the post. I found the function has_block but how to I combine this with the render_callback? The callback is only executed when the block is rendered. Is there a …
Category: Web

How to pass arguments from add_settings_field() to the callback function?

I have a function like this: add_settings_field( 'contact_phone', 'Contact Phone', 'settings_callback', 'general'); That works. It calls settings_callback. Cool. The problem I have with this is: I don't want to have to define a callback function for every setting I add, if all I'm doing is echoing out a little bit of stuff. function settings_callback() { echo '<input id="contact_phone" type="text" class="regular-text" name="contact_phone" />'; } Why on earth should I have to do that? The id, class, and name should all be …
Category: Web

Add parameters to 3rd party callback function

I have been working on a WordPress plugin and have used the do_shortcode() to implement some functionality within a form...a file upload. The upload processing comes from a 3rd party plugin and It works brilliantly. BUT now I have a problem. I want to assign the name of the file being uploaded to a record in the database, within my plugin. However the identifiers to that db record is not presently available within the callback hook, provided by the 3rd …
Category: Web

How to customize 'children comments' in Wordpress?

Hey i am using a callback for wp_list_comments. I took the Code from here - 5balloons.info/custom-html-for-comments-section-in-wordpress-theme/ Now children comments are out of main comment (means children comment's <ol> list is out of the parent comment's <li>. Let's check an example - <ol class="list-of-comments"> <li class="parent-comment-1">Anything</li> <ol class="children"><li></li></ol> </ol> so how to change children comments ol to ul. how to add a class to this. how to move it inside parent-comment-1(1 is id of comment) So overall how to customize children …
Category: Web

Warning: call_user_func_array() expects parameter 1 to be a valid callback - whenever i navigate to wp-admin

whenever i navigate to URL/wp-admin/ i face this error: Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in /customers/0/c/3/saifaljazira.com/httpd.www/wp-includes/class-wp-hook.php on line 288 here is the function of error: public function apply_filters( $value, $args ) { if ( ! $this->callbacks ) { return $value; } $nesting_level = $this->nesting_level++; $this->iterations[ $nesting_level ] = array_keys( $this->callbacks ); $num_args = count( $args ); do { $this->current_priority[ $nesting_level ] = current( $this->iterations[ …
Category: Web

WP showing "warning: call_user_func_array()", What to do?

I am currently working on designing my blog and am almost done but when I updated to 5.1 WordPress version in XAMPP, it started showing up this error message: Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'disable_embeds_rewrites' not found or invalid function name in E:\xampp\htdocs\wp\wp-includes\class-wp-hook.php on line 286 The blog theme(with custom callback for comments) I had just designed was working properly in last version of WordPress but this error started showing up just after I …
Category: Web

I would like to add a review count of a particular website in to my blog and that it should update automatically every time it changes

Hey i would like to be able to add a review count from google reviews or trustpilot of someone else website that i am writing about them in my blog. i would like it to be accurate and therefore update every time it is changed on trustpilot so for expample if the review count is 4.8 now and then it changes to 4.9 - i would like this to reflect on my website where the 4.8 currently is. What code …
Category: Web

Image upload callback in new 3.5 media

I am using new 3.5 media uploader in my theme frontend (base on this example). It is very simple when you want to do something with images after the 'Select' button is pressed: file_frame.on('select', function() { // Get all attachments var attachments = file_frame.state().get('selection').toJSON(); // Do stuff with attachments }); But what if I want to do something with attachments just after they were upload? Something like: file_frame.on('upload', function() { // Do stuff with attachments }); I didn't find anything …
Category: Web

How to 'clone' select metabox options with a callback function?

Here is my metabox array( 'id' => 'all_btns', 'name' => 'Button Select', 'type' => 'select', 'options' => array( 'button' => 'Button', 'button_red' => 'Button Red', 'button_yellow' => 'Button Yellow', ), 'callback' => 'metabox_clone_options', ), I want to clone this options to another metabox array
Category: Web

Run function after a post has finished saving - callback function perhaps?

Upon saving a new post (of a certain post type), a given operation has to run. The problem is that the operation is calling an external (slow) API, which means that the (not logget in) end-user might having to wait for 20-30 seconds, upon creating this new post (not good for the user-experience). My own solution (not implemented yet) User clicks 'create'. The post gets saved (without calling that external API). Upon that initial save-operation a post_meta-field is saved: update_post_meta( …
Category: Web

Creating a Callback URL for Wordpress Woocommerce to update Order Status

I want to create a Callback URL to update the order status when data in JSON format is POST to it. Post Format Example: "hash": "43745580XXXXXXXXXXXXXXXXXXXXXX", "status_feed": [{ "order_id": "123456", "awbno": "1348616939310", "pickupdate": "2017-11-27 19:00:00", "current_status_desc": "Out for Delivery", "current_status": "OOD", "from": "GURGAON", "to": "BAHARAICH", "status_time": "2017-12-09 13:41:00", "scans": [{ "time": "2017-12-09 13:41:00", "status": "Out for delivery", "location": "Bahraich_Kotwali_D (Uttar Pradesh)" }, { "time": "2017-12-08 20:44:00", "status": "Asked for delay delivery on 2017-12-09", "location": "Bahraich_Kotwali_D (Uttar Pradesh)" }, { "time": …
Category: Web

How to pass variable via $callback_args for add_meta_box

I am trying to pass a variable to the callback function through add_meta_box. I know that there is $callback_args that can be used to pass the variable. But somehow I just can't get it to work within a class. This is my code: class myclass{ //...blah blah...adding action function add_ex_field() { add_meta_box( 'apextadmin', __( 'My Custom Field', 'myplugin_textdomain'), array($this,'the_callback_function'), post, //the $param is some value that is saved in my option table. array('test' => $param) ); } //do I need …
Category: Web

How to check if which hook triggered the call to a function?

I have a situation where I have a function hooked to more than one custom hooks. How to check in the callback function which custom hook triggered the call? Or the question in code will be add_action('my_test_hook_1','my_test_callback_function'); add_action('my_test_hook_2','my_test_callback_function'); add_action('my_test_hook_3','my_test_callback_function'); add_action('my_test_hook_4','my_test_callback_function'); function my_test_callback_function(){ $called_action_hook = ; //Some magic code that will return current called action the hook echo "This function is called by action: " . $called_action_hook ; }
Category: Web

Can an action callback prevent the parent from continuing execution?

I'm working on a plugin that interacts with Gravity Forms, and under certain conditions I want to prevent a form from being deleted. Here's the method in Gravity Forms that handles deleting a form: public static function delete_form($form_id){ global $wpdb; if(!GFCommon::current_user_can_any("gravityforms_delete_forms")) die(__("You don't have adequate permission to delete forms.", "gravityforms")); do_action("gform_before_delete_form", $form_id); $form_meta_table = self::get_meta_table_name(); $form_table = self::get_form_table_name(); //Deleting form Entries self::delete_leads_by_form($form_id); //Delete form meta $sql = $wpdb->prepare("DELETE FROM $form_meta_table WHERE form_id=%d", $form_id); $wpdb->query($sql); //Deleting form Views self::delete_views($form_id); //Delete form …
Category: Web

Shortcode function executed twice?

I use a shortcode function to do some processing as a callback from external service. I created a page, the only content of which is the shortcode. User is redirected to this page from external function to trigger some data processing and inform user about the result. The problem is: the page shows an error, because the specified data have already been processed. Further investigation revealed that the processing function is called twice on a single request. Is it normal …
Category: Web

JavaScript missing from shortcode content

I am trying to add a short javascript as part of registering a WP shortcode. You can see my simplified code below. When I execute this on my website everything loads fine except for the part between the <script> ... </script> tags. I looked at the source code after the page has loaded and neither the <script> tags nor the function in between is there. I don't know what I'm doing wrong. Is there a filter in WP that removes …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.