Skip to content

Commit

Permalink
plugins.jquery.com: convert mu-plugins magic to regular plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Sep 8, 2023
1 parent 5a88600 commit bd3069d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 56 deletions.
9 changes: 1 addition & 8 deletions mu-plugins/_loader.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?php

$live_domain = JQUERY_LIVE_DOMAIN;
if ( 0 === validate_file( $live_domain ) ) {
foreach ( (array) glob( dirname( __FILE__ ) . "/$live_domain/*.php" ) as $domain_specific_file ) {
require_once( $domain_specific_file );
}
}
unset( $live_domain, $domain_specific_file );

// Enabled everywhere
require_once WPMU_PLUGIN_DIR . '/relevanssi/relevanssi.php';
require 'disable-emojis/disable-emojis.php';
47 changes: 0 additions & 47 deletions mu-plugins/plugins.jquery.com/xmlrpc.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* Plugin Name: Post Type - jQuery Plugin
* Plugin Name: plugins.jquery.com site mod
* Description: Custom Post Type and XML-RPC methods for plugins.jquery.com.
*/

// Prevent default redirects
Expand Down Expand Up @@ -89,3 +90,45 @@ function jquery_update_plugin_tag_count( $terms, $taxonomy ) {
do_action( 'edited_term_taxonomy', $term, $taxonomy );
}
}

function jq_pjc_get_post_for_plugin( $args ) {
global $wp_xmlrpc_server;
$wp_xmlrpc_server->escape( $args );

// Authenticate
$blog_id = $args[0];
$username = $args[1];
$password = $args[2];

if ( ! $user = $wp_xmlrpc_server->login( $username, $password ) ) {
return $wp_xmlrpc_server->error;
}

// Find post
$plugin_name = $args[3];
$query = new WP_Query( array(
'post_type' => 'jquery_plugin',
'name' => $plugin_name,
'update_post_term_cache' => false,
'update_post_meta_cache' => false,
));

if ( empty( $query->posts ) ) {
return null;
}

// Delegate to wp_getPost() for consistent return values
return $wp_xmlrpc_server->wp_getPost(array(
$blog_id,
$username,
$password,
$query->posts[0]->ID
));
}

function jq_pjc_register_xmlrpc_methods( $methods ) {
$methods[ 'jq-pjc.getPostForPlugin' ] = 'jq_pjc_get_post_for_plugin';
return $methods;
}

add_filter( 'xmlrpc_methods', 'jq_pjc_register_xmlrpc_methods' );
3 changes: 3 additions & 0 deletions sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ function jquery_sites() {
'options' => array(
'blogname' => 'jQuery Plugin Registry',
'stylesheet' => 'plugins.jquery.com',
'active_plugins' => array(
'jquery-plugins-site.php',
),
'jquery_body_class' => 'jquery',
),
),
Expand Down

0 comments on commit bd3069d

Please sign in to comment.