Advanced Integration – WordPress + YOURLS

I would probably go about this way: The plugin has a function called: wp_ozh_yourls_send_tweet($tweet); as you can see it accepts the tweet message and posts it to twitter, also it has another function called: wp_ozh_yourls_geturl( $post_id ); which accepts a post id and returns a shorturl as string. so after knowing that I would use … Read more

How to get title tag of an external page with http api?

here is a function i have for that: function get_page_title($url){ if( !class_exists( ‘WP_Http’ ) ) include_once( ABSPATH . WPINC. ‘/class-http.php’ ); $request = new WP_Http; $result = $request->request( $url ); if( is_wp_error( $result ) ) return false; if( preg_match(“#<title>(.+)<\/title>#iU”, $result[‘body’], $t)) { return trim($t[1]); } else { return false; } } Usage: $title = get_page_title(‘http://www.google.com’); … Read more

Custom routing for plugins

The WordPress Way of doing it is using query_vars so first you add you vars to the array: //add to query vars function add_query_vars($vars) { $new_vars = array(‘custom_method’,’cm_parameter’); $vars = $new_vars + $vars; return $vars; } add_filter(‘query_vars’, ‘add_query_vars’); then you can check in your plugin for the vars: global $wp; if (array_key_exists(‘custom_method’, $wp->query_vars) && isset($wp->query_vars[‘custom_method’])){ … Read more

API for Post Stats for Self-Hosted WordPress using JetPack [closed]

There is indeed a Stats API that will allow you to access stats from a WordPress.com or a Jetpack site. You can read more about it here: http://stats.wordpress.com/csv.php http://phoxis.org/2011/04/24/wordpress-com-stats-api/ http://wpgr.org/2013/03/02/rendering-jetpack-stats/ Jetpack uses this API to populate the Top Posts widget: http://plugins.trac.wordpress.org/browser/jetpack/tags/2.5/modules/widgets/top-posts.php#L223

How to check if WordPress is updating plugins?

Instead of re-ordering your plugins to load in a specific order, have each of them that requires some other plugin to be loaded to defer their initialization until the “plugins_loaded” action hook. In other words, when a plugin with a dependency is included and ran, it shouldn’t do anything directly. Instead, it should have functions, … Read more

REST-API: extend media-endpoint

I found the solution for my problem. The object type for media is not media, it’s just attachment. So the following code works for me: <?php /** * Plugin Name: REST Response Modifier * Description: A simple plugin to modify the rest api * Author: TheBalco * Author URI: http://somepage.dev */ add_action(‘rest_api_init’, ‘tb_add_custom_rest_fields’); function tb_add_custom_rest_fields() … Read more

Show different Customizer Settings on Page-Tamplates

The customizer API offers active_callback methods on both the control andd section classes. Basically you use either an conditional or a custom function to determine if a control or section is shown to the user. If you want a section to appear only for pages, you would do somthing like this: $wp_customize->add_section( ‘wpse_283821_acme_pages’, array( ‘title’ … Read more

Hide/show customizer controls based on other settings in Customizer

you can define the conditional display on definition in PHP with somethign like that : $wp_customize->add_control(“course_instructor_layout”, [ // … other arguments “settings” => “course_instructor_layout”, “active_callback” => function ($control) { return !$control->manager->get_setting(“lmscore_improved_summary”)->value(); }, ]); if that doesn’t work in your case, edit your question to add the complete definition of lmscore_improved_summary and course_instructor_layout.

Stuck with wp_remote_post sending data to an external api on user registration

I recommend only setting the arguments you absolutely need to change from defaults, to eliminate potential issues while testing. It’s best to only add additional arguments as they are needed. All arguments can be found here: https://developer.wordpress.org/reference/classes/WP_Http/request/ If possible also remove the required authentication at first to just test the POST before adding in security/authentication. … Read more