| | 260 | } |
|---|
| | 261 | |
|---|
| | 262 | function initialise_blog_option_info( ) { |
|---|
| | 263 | global $wp_version; |
|---|
| | 264 | |
|---|
| | 265 | $this->blog_options = array( |
|---|
| | 266 | // Read only options |
|---|
| | 267 | 'software_name' => array( |
|---|
| | 268 | 'desc' => __( 'Software Name' ), |
|---|
| | 269 | 'readonly' => true, |
|---|
| | 270 | 'value' => 'WordPress' |
|---|
| | 271 | ), |
|---|
| | 272 | 'software_version' => array( |
|---|
| | 273 | 'desc' => __( 'Software Version' ), |
|---|
| | 274 | 'readonly' => true, |
|---|
| | 275 | 'value' => $wp_version |
|---|
| | 276 | ), |
|---|
| | 277 | 'blog_url' => array( |
|---|
| | 278 | 'desc' => __( 'Blog URL' ), |
|---|
| | 279 | 'readonly' => true, |
|---|
| | 280 | 'option' => 'siteurl' |
|---|
| | 281 | ), |
|---|
| | 282 | |
|---|
| | 283 | // Updatable options |
|---|
| | 284 | 'time_zone' => array( |
|---|
| | 285 | 'desc' => __( 'Time Zone' ), |
|---|
| | 286 | 'readonly' => false, |
|---|
| | 287 | 'option' => 'gmt_offset' |
|---|
| | 288 | ), |
|---|
| | 289 | 'blog_title' => array( |
|---|
| | 290 | 'desc' => __( 'Blog Title' ), |
|---|
| | 291 | 'readonly' => false, |
|---|
| | 292 | 'option' => 'blogname' |
|---|
| | 293 | ), |
|---|
| | 294 | 'blog_tagline' => array( |
|---|
| | 295 | 'desc' => __( 'Blog Tagline' ), |
|---|
| | 296 | 'readonly' => false, |
|---|
| | 297 | 'option' => 'blogdescription' |
|---|
| | 298 | ), |
|---|
| | 299 | 'date_format' => array( |
|---|
| | 300 | 'desc' => __( 'Date Format' ), |
|---|
| | 301 | 'readonly' => false, |
|---|
| | 302 | 'option' => 'date_format' |
|---|
| | 303 | ), |
|---|
| | 304 | 'time_format' => array( |
|---|
| | 305 | 'desc' => __( 'Time Format' ), |
|---|
| | 306 | 'readonly' => false, |
|---|
| | 307 | 'option' => 'time_format' |
|---|
| | 308 | ) |
|---|
| | 309 | ); |
|---|
| | 310 | |
|---|
| | 311 | $this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options ); |
|---|
| | 921 | function wp_getOptions( $args ) { |
|---|
| | 922 | $this->escape( $args ); |
|---|
| | 923 | |
|---|
| | 924 | $blog_id = (int) $args[0]; |
|---|
| | 925 | $username = $args[1]; |
|---|
| | 926 | $password = $args[2]; |
|---|
| | 927 | $options = (array) $args[3]; |
|---|
| | 928 | |
|---|
| | 929 | if( !$this->login_pass_ok( $username, $password ) ) |
|---|
| | 930 | return new IXR_Error( 403, __( 'Bad login/pass combination.' ) ); |
|---|
| | 931 | |
|---|
| | 932 | $user = set_current_user( 0, $username ); |
|---|
| | 933 | |
|---|
| | 934 | // If no specific options where asked for, return all of them |
|---|
| | 935 | if (count( $options ) == 0 ) { |
|---|
| | 936 | $options = array_keys($this->blog_options); |
|---|
| | 937 | } |
|---|
| | 938 | |
|---|
| | 939 | return $this->_getOptions($options); |
|---|
| | 940 | } |
|---|
| | 941 | |
|---|
| | 942 | function _getOptions($options) |
|---|
| | 943 | { |
|---|
| | 944 | $data = array( ); |
|---|
| | 945 | foreach( $options as $option ) { |
|---|
| | 946 | if( array_key_exists( $option, $this->blog_options ) ) |
|---|
| | 947 | { |
|---|
| | 948 | $data[$option] = $this->blog_options[$option]; |
|---|
| | 949 | //Is the value static or dynamic? |
|---|
| | 950 | if( isset( $data[$option]['option'] ) ) { |
|---|
| | 951 | $data[$option]['value'] = get_option( $data[$option]['option'] ); |
|---|
| | 952 | unset($data[$option]['option']); |
|---|
| | 953 | } |
|---|
| | 954 | } |
|---|
| | 955 | } |
|---|
| | 956 | |
|---|
| | 957 | return $data; |
|---|
| | 958 | } |
|---|
| | 959 | |
|---|
| | 960 | function wp_setOptions( $args ) { |
|---|
| | 961 | $this->escape( $args ); |
|---|
| | 962 | |
|---|
| | 963 | $blog_id = (int) $args[0]; |
|---|
| | 964 | $username = $args[1]; |
|---|
| | 965 | $password = $args[2]; |
|---|
| | 966 | $options = (array) $args[3]; |
|---|
| | 967 | |
|---|
| | 968 | if( !$this->login_pass_ok( $username, $password ) ) |
|---|
| | 969 | return new IXR_Error( 403, __( 'Bad login/pass combination.' ) ); |
|---|
| | 970 | |
|---|
| | 971 | $user = set_current_user( 0, $username ); |
|---|
| | 972 | if( !current_user_can( 'manage_options' ) ) |
|---|
| | 973 | return new IXR_Error( 403, __( 'You are not allowed to update options.' ) ); |
|---|
| | 974 | |
|---|
| | 975 | foreach( $options as $o_name => $o_value ) { |
|---|
| | 976 | $option_names[] = $o_name; |
|---|
| | 977 | if( empty( $o_value ) ) |
|---|
| | 978 | continue; |
|---|
| | 979 | |
|---|
| | 980 | if( !array_key_exists( $o_name, $this->blog_options ) ) |
|---|
| | 981 | continue; |
|---|
| | 982 | |
|---|
| | 983 | if( $this->blog_options[$o_name]['readonly'] == true ) |
|---|
| | 984 | continue; |
|---|
| | 985 | |
|---|
| | 986 | update_option( $this->blog_options[$o_name]['option'], $o_value ); |
|---|
| | 987 | } |
|---|
| | 988 | |
|---|
| | 989 | //Now return the updated values |
|---|
| | 990 | return $this->_getOptions($option_names); |
|---|
| | 991 | } |
|---|