PluginProbe
Statify / 1.6.3
Statify v1.6.3
2.0.2 2.0.1 trunk 0.7 0.8 0.9 1.0 1.2.8 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 All 32 releases
statify / inc / class-statify-xmlrpc.php

class-statify-xmlrpc.php in Statify 1.6.3, at inc/class-statify-xmlrpc.php

81 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Statify: Statify_XMLRPC class
4 *
5 * This file contains the derived class for the plugin's XMLRPC features.
6 *
7 * @package Statify
8 * @since 1.1
9 */
10
11 // Quit if accessed outside WP context.
12 defined( 'ABSPATH' ) || exit;
13
14 /**
15 * Statify_XMLRPC
16 *
17 * @since 1.1
18 */
19 class Statify_XMLRPC {
20
21 /**
22 * Enhancement from the XMLRPC-method.
23 *
24 * @since 1.1.0
25 * @version 1.1.0
26 *
27 * @param array $methods Array without Plugin-Callback.
28 *
29 * @return array $methods Array with Plugin-Callback.
30 */
31 public static function xmlrpc_methods( $methods ) {
32
33 $methods['statify.getStats'] = array(
34 __CLASS__,
35 'xmlrpc_callback',
36 );
37
38 return $methods;
39 }
40
41
42 /**
43 * Ausführung der XMLRPC-Anfrage
44 *
45 * @since 1.1.0
46 * @version 1.2.5
47 *
48 * @param array $args Array with parameters (access data).
49 *
50 * @return string String with results.
51 */
52 public static function xmlrpc_callback( $args ) {
53
54 // No access data?
55 if ( empty( $args[0] ) || empty( $args[1] ) ) {
56 return '{"error": "Empty login data"}';
57 }
58
59 // Login.
60 $user = wp_authenticate( $args[0], $args[1] );
61
62 // Wrong access data.
63 if ( ! $user || is_wp_error( $user ) ) {
64 return '{"error": "Incorrect login"}';
65 }
66
67 // Check access rights.
68 if ( ! user_can( $user, 'edit_dashboard' ) ) {
69 return '{"error": "User can check failed"}';
70 }
71
72 // Empty?
73 $data = Statify_Dashboard::get_stats();
74 if ( ! $data ) {
75 return '{"error": "No data"}';
76 }
77
78 return wp_json_encode( $data['visits'] );
79 }
80 }
81