Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-inclu...
File: class-wp-xmlrpc-server.php
/**
[3000] Fix | Delete
* Retrieves Pages.
[3001] Fix | Delete
*
[3002] Fix | Delete
* @since 2.2.0
[3003] Fix | Delete
*
[3004] Fix | Delete
* @param array $args {
[3005] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3006] Fix | Delete
*
[3007] Fix | Delete
* @type int $0 Blog ID (unused).
[3008] Fix | Delete
* @type string $1 Username.
[3009] Fix | Delete
* @type string $2 Password.
[3010] Fix | Delete
* @type int $3 Optional. Number of pages. Default 10.
[3011] Fix | Delete
* }
[3012] Fix | Delete
* @return array|IXR_Error
[3013] Fix | Delete
*/
[3014] Fix | Delete
public function wp_getPages( $args ) {
[3015] Fix | Delete
$this->escape( $args );
[3016] Fix | Delete
[3017] Fix | Delete
$username = $args[1];
[3018] Fix | Delete
$password = $args[2];
[3019] Fix | Delete
$num_pages = isset( $args[3] ) ? (int) $args[3] : 10;
[3020] Fix | Delete
[3021] Fix | Delete
$user = $this->login( $username, $password );
[3022] Fix | Delete
if ( ! $user ) {
[3023] Fix | Delete
return $this->error;
[3024] Fix | Delete
}
[3025] Fix | Delete
[3026] Fix | Delete
if ( ! current_user_can( 'edit_pages' ) ) {
[3027] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) );
[3028] Fix | Delete
}
[3029] Fix | Delete
[3030] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3031] Fix | Delete
do_action( 'xmlrpc_call', 'wp.getPages', $args, $this );
[3032] Fix | Delete
[3033] Fix | Delete
$pages = get_posts(
[3034] Fix | Delete
array(
[3035] Fix | Delete
'post_type' => 'page',
[3036] Fix | Delete
'post_status' => 'any',
[3037] Fix | Delete
'numberposts' => $num_pages,
[3038] Fix | Delete
)
[3039] Fix | Delete
);
[3040] Fix | Delete
$num_pages = count( $pages );
[3041] Fix | Delete
[3042] Fix | Delete
// If we have pages, put together their info.
[3043] Fix | Delete
if ( $num_pages >= 1 ) {
[3044] Fix | Delete
$pages_struct = array();
[3045] Fix | Delete
[3046] Fix | Delete
foreach ( $pages as $page ) {
[3047] Fix | Delete
if ( current_user_can( 'edit_page', $page->ID ) ) {
[3048] Fix | Delete
$pages_struct[] = $this->_prepare_page( $page );
[3049] Fix | Delete
}
[3050] Fix | Delete
}
[3051] Fix | Delete
[3052] Fix | Delete
return $pages_struct;
[3053] Fix | Delete
}
[3054] Fix | Delete
[3055] Fix | Delete
return array();
[3056] Fix | Delete
}
[3057] Fix | Delete
[3058] Fix | Delete
/**
[3059] Fix | Delete
* Creates a new page.
[3060] Fix | Delete
*
[3061] Fix | Delete
* @since 2.2.0
[3062] Fix | Delete
*
[3063] Fix | Delete
* @see wp_xmlrpc_server::mw_newPost()
[3064] Fix | Delete
*
[3065] Fix | Delete
* @param array $args {
[3066] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3067] Fix | Delete
*
[3068] Fix | Delete
* @type int $0 Blog ID (unused).
[3069] Fix | Delete
* @type string $1 Username.
[3070] Fix | Delete
* @type string $2 Password.
[3071] Fix | Delete
* @type array $3 Content struct.
[3072] Fix | Delete
* }
[3073] Fix | Delete
* @return int|IXR_Error
[3074] Fix | Delete
*/
[3075] Fix | Delete
public function wp_newPage( $args ) {
[3076] Fix | Delete
// Items not escaped here will be escaped in wp_newPost().
[3077] Fix | Delete
$username = $this->escape( $args[1] );
[3078] Fix | Delete
$password = $this->escape( $args[2] );
[3079] Fix | Delete
[3080] Fix | Delete
$user = $this->login( $username, $password );
[3081] Fix | Delete
if ( ! $user ) {
[3082] Fix | Delete
return $this->error;
[3083] Fix | Delete
}
[3084] Fix | Delete
[3085] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3086] Fix | Delete
do_action( 'xmlrpc_call', 'wp.newPage', $args, $this );
[3087] Fix | Delete
[3088] Fix | Delete
// Mark this as content for a page.
[3089] Fix | Delete
$args[3]['post_type'] = 'page';
[3090] Fix | Delete
[3091] Fix | Delete
// Let mw_newPost() do all of the heavy lifting.
[3092] Fix | Delete
return $this->mw_newPost( $args );
[3093] Fix | Delete
}
[3094] Fix | Delete
[3095] Fix | Delete
/**
[3096] Fix | Delete
* Deletes a page.
[3097] Fix | Delete
*
[3098] Fix | Delete
* @since 2.2.0
[3099] Fix | Delete
*
[3100] Fix | Delete
* @param array $args {
[3101] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3102] Fix | Delete
*
[3103] Fix | Delete
* @type int $0 Blog ID (unused).
[3104] Fix | Delete
* @type string $1 Username.
[3105] Fix | Delete
* @type string $2 Password.
[3106] Fix | Delete
* @type int $3 Page ID.
[3107] Fix | Delete
* }
[3108] Fix | Delete
* @return true|IXR_Error True, if success.
[3109] Fix | Delete
*/
[3110] Fix | Delete
public function wp_deletePage( $args ) {
[3111] Fix | Delete
$this->escape( $args );
[3112] Fix | Delete
[3113] Fix | Delete
$username = $args[1];
[3114] Fix | Delete
$password = $args[2];
[3115] Fix | Delete
$page_id = (int) $args[3];
[3116] Fix | Delete
[3117] Fix | Delete
$user = $this->login( $username, $password );
[3118] Fix | Delete
if ( ! $user ) {
[3119] Fix | Delete
return $this->error;
[3120] Fix | Delete
}
[3121] Fix | Delete
[3122] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3123] Fix | Delete
do_action( 'xmlrpc_call', 'wp.deletePage', $args, $this );
[3124] Fix | Delete
[3125] Fix | Delete
/*
[3126] Fix | Delete
* Get the current page based on the 'page_id' and
[3127] Fix | Delete
* make sure it is a page and not a post.
[3128] Fix | Delete
*/
[3129] Fix | Delete
$actual_page = get_post( $page_id, ARRAY_A );
[3130] Fix | Delete
if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
[3131] Fix | Delete
return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
[3132] Fix | Delete
}
[3133] Fix | Delete
[3134] Fix | Delete
// Make sure the user can delete pages.
[3135] Fix | Delete
if ( ! current_user_can( 'delete_page', $page_id ) ) {
[3136] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this page.' ) );
[3137] Fix | Delete
}
[3138] Fix | Delete
[3139] Fix | Delete
// Attempt to delete the page.
[3140] Fix | Delete
$result = wp_delete_post( $page_id );
[3141] Fix | Delete
if ( ! $result ) {
[3142] Fix | Delete
return new IXR_Error( 500, __( 'Failed to delete the page.' ) );
[3143] Fix | Delete
}
[3144] Fix | Delete
[3145] Fix | Delete
/**
[3146] Fix | Delete
* Fires after a page has been successfully deleted via XML-RPC.
[3147] Fix | Delete
*
[3148] Fix | Delete
* @since 3.4.0
[3149] Fix | Delete
*
[3150] Fix | Delete
* @param int $page_id ID of the deleted page.
[3151] Fix | Delete
* @param array $args An array of arguments to delete the page.
[3152] Fix | Delete
*/
[3153] Fix | Delete
do_action( 'xmlrpc_call_success_wp_deletePage', $page_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
[3154] Fix | Delete
[3155] Fix | Delete
return true;
[3156] Fix | Delete
}
[3157] Fix | Delete
[3158] Fix | Delete
/**
[3159] Fix | Delete
* Edits a page.
[3160] Fix | Delete
*
[3161] Fix | Delete
* @since 2.2.0
[3162] Fix | Delete
*
[3163] Fix | Delete
* @param array $args {
[3164] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3165] Fix | Delete
*
[3166] Fix | Delete
* @type int $0 Blog ID (unused).
[3167] Fix | Delete
* @type int $1 Page ID.
[3168] Fix | Delete
* @type string $2 Username.
[3169] Fix | Delete
* @type string $3 Password.
[3170] Fix | Delete
* @type string $4 Content.
[3171] Fix | Delete
* @type int $5 Publish flag. 0 for draft, 1 for publish.
[3172] Fix | Delete
* }
[3173] Fix | Delete
* @return array|IXR_Error
[3174] Fix | Delete
*/
[3175] Fix | Delete
public function wp_editPage( $args ) {
[3176] Fix | Delete
// Items will be escaped in mw_editPost().
[3177] Fix | Delete
$page_id = (int) $args[1];
[3178] Fix | Delete
$username = $args[2];
[3179] Fix | Delete
$password = $args[3];
[3180] Fix | Delete
$content = $args[4];
[3181] Fix | Delete
$publish = $args[5];
[3182] Fix | Delete
[3183] Fix | Delete
$escaped_username = $this->escape( $username );
[3184] Fix | Delete
$escaped_password = $this->escape( $password );
[3185] Fix | Delete
[3186] Fix | Delete
$user = $this->login( $escaped_username, $escaped_password );
[3187] Fix | Delete
if ( ! $user ) {
[3188] Fix | Delete
return $this->error;
[3189] Fix | Delete
}
[3190] Fix | Delete
[3191] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3192] Fix | Delete
do_action( 'xmlrpc_call', 'wp.editPage', $args, $this );
[3193] Fix | Delete
[3194] Fix | Delete
// Get the page data and make sure it is a page.
[3195] Fix | Delete
$actual_page = get_post( $page_id, ARRAY_A );
[3196] Fix | Delete
if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
[3197] Fix | Delete
return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
[3198] Fix | Delete
}
[3199] Fix | Delete
[3200] Fix | Delete
// Make sure the user is allowed to edit pages.
[3201] Fix | Delete
if ( ! current_user_can( 'edit_page', $page_id ) ) {
[3202] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) );
[3203] Fix | Delete
}
[3204] Fix | Delete
[3205] Fix | Delete
// Mark this as content for a page.
[3206] Fix | Delete
$content['post_type'] = 'page';
[3207] Fix | Delete
[3208] Fix | Delete
// Arrange args in the way mw_editPost() understands.
[3209] Fix | Delete
$args = array(
[3210] Fix | Delete
$page_id,
[3211] Fix | Delete
$username,
[3212] Fix | Delete
$password,
[3213] Fix | Delete
$content,
[3214] Fix | Delete
$publish,
[3215] Fix | Delete
);
[3216] Fix | Delete
[3217] Fix | Delete
// Let mw_editPost() do all of the heavy lifting.
[3218] Fix | Delete
return $this->mw_editPost( $args );
[3219] Fix | Delete
}
[3220] Fix | Delete
[3221] Fix | Delete
/**
[3222] Fix | Delete
* Retrieves page list.
[3223] Fix | Delete
*
[3224] Fix | Delete
* @since 2.2.0
[3225] Fix | Delete
*
[3226] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3227] Fix | Delete
*
[3228] Fix | Delete
* @param array $args {
[3229] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3230] Fix | Delete
*
[3231] Fix | Delete
* @type int $0 Blog ID (unused).
[3232] Fix | Delete
* @type string $1 Username.
[3233] Fix | Delete
* @type string $2 Password.
[3234] Fix | Delete
* }
[3235] Fix | Delete
* @return array|IXR_Error
[3236] Fix | Delete
*/
[3237] Fix | Delete
public function wp_getPageList( $args ) {
[3238] Fix | Delete
global $wpdb;
[3239] Fix | Delete
[3240] Fix | Delete
$this->escape( $args );
[3241] Fix | Delete
[3242] Fix | Delete
$username = $args[1];
[3243] Fix | Delete
$password = $args[2];
[3244] Fix | Delete
[3245] Fix | Delete
$user = $this->login( $username, $password );
[3246] Fix | Delete
if ( ! $user ) {
[3247] Fix | Delete
return $this->error;
[3248] Fix | Delete
}
[3249] Fix | Delete
[3250] Fix | Delete
if ( ! current_user_can( 'edit_pages' ) ) {
[3251] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) );
[3252] Fix | Delete
}
[3253] Fix | Delete
[3254] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3255] Fix | Delete
do_action( 'xmlrpc_call', 'wp.getPageList', $args, $this );
[3256] Fix | Delete
[3257] Fix | Delete
// Get list of page IDs and titles.
[3258] Fix | Delete
$page_list = $wpdb->get_results(
[3259] Fix | Delete
"
[3260] Fix | Delete
SELECT ID page_id,
[3261] Fix | Delete
post_title page_title,
[3262] Fix | Delete
post_parent page_parent_id,
[3263] Fix | Delete
post_date_gmt,
[3264] Fix | Delete
post_date,
[3265] Fix | Delete
post_status
[3266] Fix | Delete
FROM {$wpdb->posts}
[3267] Fix | Delete
WHERE post_type = 'page'
[3268] Fix | Delete
ORDER BY ID
[3269] Fix | Delete
"
[3270] Fix | Delete
);
[3271] Fix | Delete
[3272] Fix | Delete
// The date needs to be formatted properly.
[3273] Fix | Delete
$num_pages = count( $page_list );
[3274] Fix | Delete
for ( $i = 0; $i < $num_pages; $i++ ) {
[3275] Fix | Delete
$page_list[ $i ]->dateCreated = $this->_convert_date( $page_list[ $i ]->post_date );
[3276] Fix | Delete
$page_list[ $i ]->date_created_gmt = $this->_convert_date_gmt( $page_list[ $i ]->post_date_gmt, $page_list[ $i ]->post_date );
[3277] Fix | Delete
[3278] Fix | Delete
unset( $page_list[ $i ]->post_date_gmt );
[3279] Fix | Delete
unset( $page_list[ $i ]->post_date );
[3280] Fix | Delete
unset( $page_list[ $i ]->post_status );
[3281] Fix | Delete
}
[3282] Fix | Delete
[3283] Fix | Delete
return $page_list;
[3284] Fix | Delete
}
[3285] Fix | Delete
[3286] Fix | Delete
/**
[3287] Fix | Delete
* Retrieves authors list.
[3288] Fix | Delete
*
[3289] Fix | Delete
* @since 2.2.0
[3290] Fix | Delete
*
[3291] Fix | Delete
* @param array $args {
[3292] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3293] Fix | Delete
*
[3294] Fix | Delete
* @type int $0 Blog ID (unused).
[3295] Fix | Delete
* @type string $1 Username.
[3296] Fix | Delete
* @type string $2 Password.
[3297] Fix | Delete
* }
[3298] Fix | Delete
* @return array|IXR_Error
[3299] Fix | Delete
*/
[3300] Fix | Delete
public function wp_getAuthors( $args ) {
[3301] Fix | Delete
$this->escape( $args );
[3302] Fix | Delete
[3303] Fix | Delete
$username = $args[1];
[3304] Fix | Delete
$password = $args[2];
[3305] Fix | Delete
[3306] Fix | Delete
$user = $this->login( $username, $password );
[3307] Fix | Delete
if ( ! $user ) {
[3308] Fix | Delete
return $this->error;
[3309] Fix | Delete
}
[3310] Fix | Delete
[3311] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[3312] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
[3313] Fix | Delete
}
[3314] Fix | Delete
[3315] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3316] Fix | Delete
do_action( 'xmlrpc_call', 'wp.getAuthors', $args, $this );
[3317] Fix | Delete
[3318] Fix | Delete
$authors = array();
[3319] Fix | Delete
foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) {
[3320] Fix | Delete
$authors[] = array(
[3321] Fix | Delete
'user_id' => $user->ID,
[3322] Fix | Delete
'user_login' => $user->user_login,
[3323] Fix | Delete
'display_name' => $user->display_name,
[3324] Fix | Delete
);
[3325] Fix | Delete
}
[3326] Fix | Delete
[3327] Fix | Delete
return $authors;
[3328] Fix | Delete
}
[3329] Fix | Delete
[3330] Fix | Delete
/**
[3331] Fix | Delete
* Gets the list of all tags.
[3332] Fix | Delete
*
[3333] Fix | Delete
* @since 2.7.0
[3334] Fix | Delete
*
[3335] Fix | Delete
* @param array $args {
[3336] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3337] Fix | Delete
*
[3338] Fix | Delete
* @type int $0 Blog ID (unused).
[3339] Fix | Delete
* @type string $1 Username.
[3340] Fix | Delete
* @type string $2 Password.
[3341] Fix | Delete
* }
[3342] Fix | Delete
* @return array|IXR_Error
[3343] Fix | Delete
*/
[3344] Fix | Delete
public function wp_getTags( $args ) {
[3345] Fix | Delete
$this->escape( $args );
[3346] Fix | Delete
[3347] Fix | Delete
$username = $args[1];
[3348] Fix | Delete
$password = $args[2];
[3349] Fix | Delete
[3350] Fix | Delete
$user = $this->login( $username, $password );
[3351] Fix | Delete
if ( ! $user ) {
[3352] Fix | Delete
return $this->error;
[3353] Fix | Delete
}
[3354] Fix | Delete
[3355] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[3356] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) );
[3357] Fix | Delete
}
[3358] Fix | Delete
[3359] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3360] Fix | Delete
do_action( 'xmlrpc_call', 'wp.getKeywords', $args, $this );
[3361] Fix | Delete
[3362] Fix | Delete
$tags = array();
[3363] Fix | Delete
[3364] Fix | Delete
$all_tags = get_tags();
[3365] Fix | Delete
if ( $all_tags ) {
[3366] Fix | Delete
foreach ( (array) $all_tags as $tag ) {
[3367] Fix | Delete
$struct = array();
[3368] Fix | Delete
$struct['tag_id'] = $tag->term_id;
[3369] Fix | Delete
$struct['name'] = $tag->name;
[3370] Fix | Delete
$struct['count'] = $tag->count;
[3371] Fix | Delete
$struct['slug'] = $tag->slug;
[3372] Fix | Delete
$struct['html_url'] = esc_html( get_tag_link( $tag->term_id ) );
[3373] Fix | Delete
$struct['rss_url'] = esc_html( get_tag_feed_link( $tag->term_id ) );
[3374] Fix | Delete
[3375] Fix | Delete
$tags[] = $struct;
[3376] Fix | Delete
}
[3377] Fix | Delete
}
[3378] Fix | Delete
[3379] Fix | Delete
return $tags;
[3380] Fix | Delete
}
[3381] Fix | Delete
[3382] Fix | Delete
/**
[3383] Fix | Delete
* Creates a new category.
[3384] Fix | Delete
*
[3385] Fix | Delete
* @since 2.2.0
[3386] Fix | Delete
*
[3387] Fix | Delete
* @param array $args {
[3388] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3389] Fix | Delete
*
[3390] Fix | Delete
* @type int $0 Blog ID (unused).
[3391] Fix | Delete
* @type string $1 Username.
[3392] Fix | Delete
* @type string $2 Password.
[3393] Fix | Delete
* @type array $3 Category.
[3394] Fix | Delete
* }
[3395] Fix | Delete
* @return int|IXR_Error Category ID.
[3396] Fix | Delete
*/
[3397] Fix | Delete
public function wp_newCategory( $args ) {
[3398] Fix | Delete
$this->escape( $args );
[3399] Fix | Delete
[3400] Fix | Delete
$username = $args[1];
[3401] Fix | Delete
$password = $args[2];
[3402] Fix | Delete
$category = $args[3];
[3403] Fix | Delete
[3404] Fix | Delete
$user = $this->login( $username, $password );
[3405] Fix | Delete
if ( ! $user ) {
[3406] Fix | Delete
return $this->error;
[3407] Fix | Delete
}
[3408] Fix | Delete
[3409] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3410] Fix | Delete
do_action( 'xmlrpc_call', 'wp.newCategory', $args, $this );
[3411] Fix | Delete
[3412] Fix | Delete
// Make sure the user is allowed to add a category.
[3413] Fix | Delete
if ( ! current_user_can( 'manage_categories' ) ) {
[3414] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) );
[3415] Fix | Delete
}
[3416] Fix | Delete
[3417] Fix | Delete
/*
[3418] Fix | Delete
* If no slug was provided, make it empty
[3419] Fix | Delete
* so that WordPress will generate one.
[3420] Fix | Delete
*/
[3421] Fix | Delete
if ( empty( $category['slug'] ) ) {
[3422] Fix | Delete
$category['slug'] = '';
[3423] Fix | Delete
}
[3424] Fix | Delete
[3425] Fix | Delete
/*
[3426] Fix | Delete
* If no parent_id was provided, make it empty
[3427] Fix | Delete
* so that it will be a top-level page (no parent).
[3428] Fix | Delete
*/
[3429] Fix | Delete
if ( ! isset( $category['parent_id'] ) ) {
[3430] Fix | Delete
$category['parent_id'] = '';
[3431] Fix | Delete
}
[3432] Fix | Delete
[3433] Fix | Delete
// If no description was provided, make it empty.
[3434] Fix | Delete
if ( empty( $category['description'] ) ) {
[3435] Fix | Delete
$category['description'] = '';
[3436] Fix | Delete
}
[3437] Fix | Delete
[3438] Fix | Delete
$new_category = array(
[3439] Fix | Delete
'cat_name' => $category['name'],
[3440] Fix | Delete
'category_nicename' => $category['slug'],
[3441] Fix | Delete
'category_parent' => $category['parent_id'],
[3442] Fix | Delete
'category_description' => $category['description'],
[3443] Fix | Delete
);
[3444] Fix | Delete
[3445] Fix | Delete
$cat_id = wp_insert_category( $new_category, true );
[3446] Fix | Delete
if ( is_wp_error( $cat_id ) ) {
[3447] Fix | Delete
if ( 'term_exists' === $cat_id->get_error_code() ) {
[3448] Fix | Delete
return (int) $cat_id->get_error_data();
[3449] Fix | Delete
} else {
[3450] Fix | Delete
return new IXR_Error( 500, __( 'Sorry, the category could not be created.' ) );
[3451] Fix | Delete
}
[3452] Fix | Delete
} elseif ( ! $cat_id ) {
[3453] Fix | Delete
return new IXR_Error( 500, __( 'Sorry, the category could not be created.' ) );
[3454] Fix | Delete
}
[3455] Fix | Delete
[3456] Fix | Delete
/**
[3457] Fix | Delete
* Fires after a new category has been successfully created via XML-RPC.
[3458] Fix | Delete
*
[3459] Fix | Delete
* @since 3.4.0
[3460] Fix | Delete
*
[3461] Fix | Delete
* @param int $cat_id ID of the new category.
[3462] Fix | Delete
* @param array $args An array of new category arguments.
[3463] Fix | Delete
*/
[3464] Fix | Delete
do_action( 'xmlrpc_call_success_wp_newCategory', $cat_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
[3465] Fix | Delete
[3466] Fix | Delete
return $cat_id;
[3467] Fix | Delete
}
[3468] Fix | Delete
[3469] Fix | Delete
/**
[3470] Fix | Delete
* Deletes a category.
[3471] Fix | Delete
*
[3472] Fix | Delete
* @since 2.5.0
[3473] Fix | Delete
*
[3474] Fix | Delete
* @param array $args {
[3475] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3476] Fix | Delete
*
[3477] Fix | Delete
* @type int $0 Blog ID (unused).
[3478] Fix | Delete
* @type string $1 Username.
[3479] Fix | Delete
* @type string $2 Password.
[3480] Fix | Delete
* @type int $3 Category ID.
[3481] Fix | Delete
* }
[3482] Fix | Delete
* @return bool|IXR_Error See wp_delete_term() for return info.
[3483] Fix | Delete
*/
[3484] Fix | Delete
public function wp_deleteCategory( $args ) {
[3485] Fix | Delete
$this->escape( $args );
[3486] Fix | Delete
[3487] Fix | Delete
$username = $args[1];
[3488] Fix | Delete
$password = $args[2];
[3489] Fix | Delete
$category_id = (int) $args[3];
[3490] Fix | Delete
[3491] Fix | Delete
$user = $this->login( $username, $password );
[3492] Fix | Delete
if ( ! $user ) {
[3493] Fix | Delete
return $this->error;
[3494] Fix | Delete
}
[3495] Fix | Delete
[3496] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3497] Fix | Delete
do_action( 'xmlrpc_call', 'wp.deleteCategory', $args, $this );
[3498] Fix | Delete
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function