Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Why is $wp_xmlrpc_server->minimum_args protected? It seems like as much of a utility method as $wp_xmlrpc_server->login. Is there some other way to sanitize the inputs for length or do I have to write my own method?

share|improve this question

1 Answer 1

You can totally swap out the class that runs the xmlrpc server. So create a subclass of wp_xmlrpc_server, use it for the xmlrpc server class, and use all the protected methods you like.

Example (not tested, use with caution):

<?php
class WPSE69959_XMLRPC_Sever extends wp_xmlrpc_server
{
    // override the constructor to add your own methods.
    public function __construct()
    {
        add_filter('xmlrpc_methods', array(__CLASS__, '_add_methods'));
        // call the parent constructor to set up the other methods
        parent::__construct();
    }

    public static function _add_methods($methods)
    {
        $methods['say_hello_two'] = 'this:say_hello_two';
        return $methods;
    }

    public function say_hello_two($args)
    {
        // do stuff with protected methods here!
    }
}

// swap out the classes
add_filter('wp_xmlrpc_server_class', 'wpse69959_swap_class');
function wpse69959_swap_class($cls)
{
    return 'WPSE69959_XMLRPC_Sever';
}

To answer your question, it's protected because it's meant to be an internal method. There would be no reason for someone outside the wp_xmlrpc_server class to use that method, so there's no reason for it to be public. Furthermore, the way it's implemented may cause unintentional side effects (like an error being set/sent) if it was used by an untrusted source -- eg. someone outside the wp_xmlrpc_server class.

share|improve this answer
    
Would swapping in my class prevent other plugins from working if they use this same code? Also, will this override the built-in Wordpress xmlrpc methods? –  Zonedabone Oct 21 '12 at 3:21
    
Not if you create a subclass of wp_xmlrpc_server and make sure you call parent::__construct(); to set up everything. –  chrisguitarguy Oct 21 '12 at 3:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.