WP API Get post with tag names instead of tag ID’s

I figured something out based on what I found at this post. Basically I need a plugin that listens for when the REST response is about to go out. The plugin code would be similar to the following: function ag_filter_post_json($response, $post, $context) { $tags = wp_get_post_tags($post->ID); $response->data[‘tag_names’] = []; foreach ($tags as $tag) { $response->data[‘tag_names’][] … Read more

fetching via fetch/ajax gutenberg block data from third party

Well, I figured it out. Though my solution is probably far from elegant (I’m not making concessions for timeouts or usability/accessibility). My problem was mostly overzealous configuration, copy and paste errors, and needing to apply async/await keywords. Attributes look like this: attributes: { url: { source: ‘attribute’, type: ‘string’, selector: ‘.o_microlink’, attribute: ‘href’, }, title: … Read more

Creating external apps WordPress / How they work

WordPress features a very rich XML-RPC interface that you can work with from external applications. It provides you access to most of the functionality you’d have directly in the admin – write posts, edit posts, edit comments, create/edit categories, manage site options, upload files, etc. As a matter of fact, certain third-party applications are already … Read more

WordPress API – count posts

Assuming you are using Linux or OS X, the easiest way is probably to use wp-cli (if present in your WordPress installation) to return a list of all posts: wp-cli post list Then pipe it to the word count tool to get the number of lines: wc -l Finally, deduct one to take care of … Read more

Does the WordPress API have Modal Dialogs

Yes, WordPress has modal dialog and it is called as Thickbox, but I am not sure how flexible it is to implement what you want to. Here is the code – <?php add_thickbox(); ?> <div id=”my-content-id” style=”display:none;”> <p> This is my hidden content! It will appear in ThickBox when the link is clicked. </p> </div> … Read more

get_userdata by username

get_userdata() function is an alias of get_user_by(‘ID’) function. Use this code: $username=”your user name”; $user = get_user_by(‘login’, $username); It will return WP_User object on success, or false on failure. See Codex. REST API: http://example.com/wp-json/wp/v2/users/<id>

Ask user permission when activating a plugin

Try the following code: add_action( ‘admin_head’, ‘ask_for_activation’ ); function ask_for_activation() { ?> <script type=”text/javascript”> jQuery(function($){ $(‘span.activate a’).click(function(e){ var c = confirm(‘Are you sure wnat to activate?’) if(!c) { e.preventDefault(); return false; } return true; }); }); </script> <?php } You can add those codes in your functions.php in the theme, if you think your theme … Read more

How Can I Use $wpdb in PayPal IPN file?

Use the ajax api: http://codex.wordpress.org/AJAX_in_Plugins If you let all your ajax calls go through this you will have access to all WP functions. Also take a look at these: http://www.james-vandyne.com/process-paypal-ipn-requests-through-wordpress/ http://wordpress.org/extend/plugins/paypal-framework/ Don’t know if what you want is in there, but worth a look.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)