Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Admin/API
File: Notes.php
* @param string $query The query, path, or URL to transform.
[500] Fix | Delete
* @return string A fully formed URL.
[501] Fix | Delete
*/
[502] Fix | Delete
public function prepare_query_for_response( $query ) {
[503] Fix | Delete
if ( empty( $query ) ) {
[504] Fix | Delete
return $query;
[505] Fix | Delete
}
[506] Fix | Delete
if ( 'https://' === substr( $query, 0, 8 ) ) {
[507] Fix | Delete
return $query;
[508] Fix | Delete
}
[509] Fix | Delete
if ( 'http://' === substr( $query, 0, 7 ) ) {
[510] Fix | Delete
return $query;
[511] Fix | Delete
}
[512] Fix | Delete
if ( '?' === substr( $query, 0, 1 ) ) {
[513] Fix | Delete
return admin_url( 'admin.php' . $query );
[514] Fix | Delete
}
[515] Fix | Delete
[516] Fix | Delete
return admin_url( $query );
[517] Fix | Delete
}
[518] Fix | Delete
[519] Fix | Delete
/**
[520] Fix | Delete
* Maybe add a nonce to a URL.
[521] Fix | Delete
*
[522] Fix | Delete
* @link https://codex.wordpress.org/WordPress_Nonces
[523] Fix | Delete
*
[524] Fix | Delete
* @param string $url The URL needing a nonce.
[525] Fix | Delete
* @param string $action The nonce action.
[526] Fix | Delete
* @param string $name The nonce name.
[527] Fix | Delete
* @return string A fully formed URL.
[528] Fix | Delete
*/
[529] Fix | Delete
private function maybe_add_nonce_to_url( string $url, string $action = '', string $name = '' ) : string {
[530] Fix | Delete
if ( empty( $action ) ) {
[531] Fix | Delete
return $url;
[532] Fix | Delete
}
[533] Fix | Delete
[534] Fix | Delete
if ( empty( $name ) ) {
[535] Fix | Delete
// Default parameter name.
[536] Fix | Delete
$name = '_wpnonce';
[537] Fix | Delete
}
[538] Fix | Delete
[539] Fix | Delete
return add_query_arg( $name, wp_create_nonce( $action ), $url );
[540] Fix | Delete
}
[541] Fix | Delete
[542] Fix | Delete
/**
[543] Fix | Delete
* Prepare a note object for serialization.
[544] Fix | Delete
*
[545] Fix | Delete
* @param array $data Note data.
[546] Fix | Delete
* @param WP_REST_Request $request Request object.
[547] Fix | Delete
* @return WP_REST_Response $response Response data.
[548] Fix | Delete
*/
[549] Fix | Delete
public function prepare_item_for_response( $data, $request ) {
[550] Fix | Delete
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
[551] Fix | Delete
$data = $this->add_additional_fields_to_object( $data, $request );
[552] Fix | Delete
$data['date_created_gmt'] = wc_rest_prepare_date_response( $data['date_created'] );
[553] Fix | Delete
$data['date_created'] = wc_rest_prepare_date_response( $data['date_created'], false );
[554] Fix | Delete
$data['date_reminder_gmt'] = wc_rest_prepare_date_response( $data['date_reminder'] );
[555] Fix | Delete
$data['date_reminder'] = wc_rest_prepare_date_response( $data['date_reminder'], false );
[556] Fix | Delete
$data['title'] = stripslashes( $data['title'] );
[557] Fix | Delete
$data['content'] = stripslashes( $data['content'] );
[558] Fix | Delete
$data['is_snoozable'] = (bool) $data['is_snoozable'];
[559] Fix | Delete
$data['is_deleted'] = (bool) $data['is_deleted'];
[560] Fix | Delete
$data['is_read'] = (bool) $data['is_read'];
[561] Fix | Delete
foreach ( (array) $data['actions'] as $key => $value ) {
[562] Fix | Delete
$data['actions'][ $key ]->label = stripslashes( $data['actions'][ $key ]->label );
[563] Fix | Delete
$data['actions'][ $key ]->url = $this->maybe_add_nonce_to_url(
[564] Fix | Delete
$this->prepare_query_for_response( $data['actions'][ $key ]->query ),
[565] Fix | Delete
(string) $data['actions'][ $key ]->nonce_action,
[566] Fix | Delete
(string) $data['actions'][ $key ]->nonce_name
[567] Fix | Delete
);
[568] Fix | Delete
$data['actions'][ $key ]->status = stripslashes( $data['actions'][ $key ]->status );
[569] Fix | Delete
}
[570] Fix | Delete
$data = $this->filter_response_by_context( $data, $context );
[571] Fix | Delete
[572] Fix | Delete
// Wrap the data in a response object.
[573] Fix | Delete
$response = rest_ensure_response( $data );
[574] Fix | Delete
$response->add_links(
[575] Fix | Delete
array(
[576] Fix | Delete
'self' => array(
[577] Fix | Delete
'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $data['id'] ) ),
[578] Fix | Delete
),
[579] Fix | Delete
'collection' => array(
[580] Fix | Delete
'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
[581] Fix | Delete
),
[582] Fix | Delete
)
[583] Fix | Delete
);
[584] Fix | Delete
/**
[585] Fix | Delete
* Filter a note returned from the API.
[586] Fix | Delete
*
[587] Fix | Delete
* Allows modification of the note data right before it is returned.
[588] Fix | Delete
*
[589] Fix | Delete
* @param WP_REST_Response $response The response object.
[590] Fix | Delete
* @param array $data The original note.
[591] Fix | Delete
* @param WP_REST_Request $request Request used to generate the response.
[592] Fix | Delete
* @since 3.9.0
[593] Fix | Delete
*/
[594] Fix | Delete
return apply_filters( 'woocommerce_rest_prepare_note', $response, $data, $request );
[595] Fix | Delete
}
[596] Fix | Delete
[597] Fix | Delete
/**
[598] Fix | Delete
* Track opened emails.
[599] Fix | Delete
*
[600] Fix | Delete
* @deprecated 10.6.0 This method is no longer functional as the email tracking feature was removed in WooCommerce 9.9.
[601] Fix | Delete
*
[602] Fix | Delete
* @param WP_REST_Request $request Request object.
[603] Fix | Delete
*/
[604] Fix | Delete
public function track_opened_email( $request ) {
[605] Fix | Delete
wc_deprecated_function( __METHOD__, '10.6.0' );
[606] Fix | Delete
}
[607] Fix | Delete
[608] Fix | Delete
/**
[609] Fix | Delete
* Get the query params for collections.
[610] Fix | Delete
*
[611] Fix | Delete
* @return array
[612] Fix | Delete
*/
[613] Fix | Delete
public function get_collection_params() {
[614] Fix | Delete
$params = array();
[615] Fix | Delete
$params['context'] = $this->get_context_param( array( 'default' => 'view' ) );
[616] Fix | Delete
$params['order'] = array(
[617] Fix | Delete
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
[618] Fix | Delete
'type' => 'string',
[619] Fix | Delete
'default' => 'desc',
[620] Fix | Delete
'enum' => array( 'asc', 'desc' ),
[621] Fix | Delete
'validate_callback' => 'rest_validate_request_arg',
[622] Fix | Delete
);
[623] Fix | Delete
$params['orderby'] = array(
[624] Fix | Delete
'description' => __( 'Sort collection by object attribute.', 'woocommerce' ),
[625] Fix | Delete
'type' => 'string',
[626] Fix | Delete
'default' => 'date',
[627] Fix | Delete
'enum' => array(
[628] Fix | Delete
'note_id',
[629] Fix | Delete
'date',
[630] Fix | Delete
'type',
[631] Fix | Delete
'title',
[632] Fix | Delete
'status',
[633] Fix | Delete
),
[634] Fix | Delete
'validate_callback' => 'rest_validate_request_arg',
[635] Fix | Delete
);
[636] Fix | Delete
$params['page'] = array(
[637] Fix | Delete
'description' => __( 'Current page of the collection.', 'woocommerce' ),
[638] Fix | Delete
'type' => 'integer',
[639] Fix | Delete
'default' => 1,
[640] Fix | Delete
'sanitize_callback' => 'absint',
[641] Fix | Delete
'validate_callback' => 'rest_validate_request_arg',
[642] Fix | Delete
'minimum' => 1,
[643] Fix | Delete
);
[644] Fix | Delete
$params['per_page'] = array(
[645] Fix | Delete
'description' => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
[646] Fix | Delete
'type' => 'integer',
[647] Fix | Delete
'default' => 10,
[648] Fix | Delete
'minimum' => 1,
[649] Fix | Delete
'maximum' => 100,
[650] Fix | Delete
'sanitize_callback' => 'absint',
[651] Fix | Delete
'validate_callback' => 'rest_validate_request_arg',
[652] Fix | Delete
);
[653] Fix | Delete
$params['type'] = array(
[654] Fix | Delete
'description' => __( 'Type of note.', 'woocommerce' ),
[655] Fix | Delete
'type' => 'array',
[656] Fix | Delete
'sanitize_callback' => 'wp_parse_slug_list',
[657] Fix | Delete
'validate_callback' => 'rest_validate_request_arg',
[658] Fix | Delete
'items' => array(
[659] Fix | Delete
'enum' => Note::get_allowed_types(),
[660] Fix | Delete
'type' => 'string',
[661] Fix | Delete
),
[662] Fix | Delete
);
[663] Fix | Delete
$params['status'] = array(
[664] Fix | Delete
'description' => __( 'Status of note.', 'woocommerce' ),
[665] Fix | Delete
'type' => 'array',
[666] Fix | Delete
'sanitize_callback' => 'wp_parse_slug_list',
[667] Fix | Delete
'validate_callback' => 'rest_validate_request_arg',
[668] Fix | Delete
'items' => array(
[669] Fix | Delete
'enum' => Note::get_allowed_statuses(),
[670] Fix | Delete
'type' => 'string',
[671] Fix | Delete
),
[672] Fix | Delete
);
[673] Fix | Delete
$params['source'] = array(
[674] Fix | Delete
'description' => __( 'Source of note.', 'woocommerce' ),
[675] Fix | Delete
'type' => 'array',
[676] Fix | Delete
'sanitize_callback' => 'wp_parse_list',
[677] Fix | Delete
'validate_callback' => 'rest_validate_request_arg',
[678] Fix | Delete
'items' => array(
[679] Fix | Delete
'type' => 'string',
[680] Fix | Delete
),
[681] Fix | Delete
);
[682] Fix | Delete
return $params;
[683] Fix | Delete
}
[684] Fix | Delete
[685] Fix | Delete
/**
[686] Fix | Delete
* Get the note's schema, conforming to JSON Schema.
[687] Fix | Delete
*
[688] Fix | Delete
* @return array
[689] Fix | Delete
*/
[690] Fix | Delete
public function get_item_schema() {
[691] Fix | Delete
$schema = array(
[692] Fix | Delete
'$schema' => 'http://json-schema.org/draft-04/schema#',
[693] Fix | Delete
'title' => 'note',
[694] Fix | Delete
'type' => 'object',
[695] Fix | Delete
'properties' => array(
[696] Fix | Delete
'id' => array(
[697] Fix | Delete
'description' => __( 'ID of the note record.', 'woocommerce' ),
[698] Fix | Delete
'type' => 'integer',
[699] Fix | Delete
'context' => array( 'view' ),
[700] Fix | Delete
'readonly' => true,
[701] Fix | Delete
),
[702] Fix | Delete
'name' => array(
[703] Fix | Delete
'description' => __( 'Name of the note.', 'woocommerce' ),
[704] Fix | Delete
'type' => 'string',
[705] Fix | Delete
'context' => array( 'view', 'edit' ),
[706] Fix | Delete
'readonly' => true,
[707] Fix | Delete
),
[708] Fix | Delete
'type' => array(
[709] Fix | Delete
'description' => __( 'The type of the note (e.g. error, warning, etc.).', 'woocommerce' ),
[710] Fix | Delete
'type' => 'string',
[711] Fix | Delete
'context' => array( 'view', 'edit' ),
[712] Fix | Delete
'readonly' => true,
[713] Fix | Delete
),
[714] Fix | Delete
'locale' => array(
[715] Fix | Delete
'description' => __( 'Locale used for the note title and content.', 'woocommerce' ),
[716] Fix | Delete
'type' => 'string',
[717] Fix | Delete
'context' => array( 'view', 'edit' ),
[718] Fix | Delete
'readonly' => true,
[719] Fix | Delete
),
[720] Fix | Delete
'title' => array(
[721] Fix | Delete
'description' => __( 'Title of the note.', 'woocommerce' ),
[722] Fix | Delete
'type' => 'string',
[723] Fix | Delete
'context' => array( 'view', 'edit' ),
[724] Fix | Delete
'readonly' => true,
[725] Fix | Delete
),
[726] Fix | Delete
'content' => array(
[727] Fix | Delete
'description' => __( 'Content of the note.', 'woocommerce' ),
[728] Fix | Delete
'type' => 'string',
[729] Fix | Delete
'context' => array( 'view', 'edit' ),
[730] Fix | Delete
'readonly' => true,
[731] Fix | Delete
),
[732] Fix | Delete
'content_data' => array(
[733] Fix | Delete
'description' => __( 'Content data for the note. JSON string. Available for re-localization.', 'woocommerce' ),
[734] Fix | Delete
'type' => 'string',
[735] Fix | Delete
'context' => array( 'view', 'edit' ),
[736] Fix | Delete
'readonly' => true,
[737] Fix | Delete
),
[738] Fix | Delete
'status' => array(
[739] Fix | Delete
'description' => __( 'The status of the note (e.g. unactioned, actioned).', 'woocommerce' ),
[740] Fix | Delete
'type' => 'string',
[741] Fix | Delete
'context' => array( 'view', 'edit' ),
[742] Fix | Delete
),
[743] Fix | Delete
'source' => array(
[744] Fix | Delete
'description' => __( 'Source of the note.', 'woocommerce' ),
[745] Fix | Delete
'type' => 'string',
[746] Fix | Delete
'context' => array( 'view', 'edit' ),
[747] Fix | Delete
'readonly' => true,
[748] Fix | Delete
),
[749] Fix | Delete
'date_created' => array(
[750] Fix | Delete
'description' => __( 'Date the note was created.', 'woocommerce' ),
[751] Fix | Delete
'type' => 'string',
[752] Fix | Delete
'context' => array( 'view', 'edit' ),
[753] Fix | Delete
'readonly' => true,
[754] Fix | Delete
),
[755] Fix | Delete
'date_created_gmt' => array(
[756] Fix | Delete
'description' => __( 'Date the note was created (GMT).', 'woocommerce' ),
[757] Fix | Delete
'type' => 'string',
[758] Fix | Delete
'context' => array( 'view', 'edit' ),
[759] Fix | Delete
'readonly' => true,
[760] Fix | Delete
),
[761] Fix | Delete
'date_reminder' => array(
[762] Fix | Delete
'description' => __( 'Date after which the user should be reminded of the note, if any.', 'woocommerce' ),
[763] Fix | Delete
'type' => 'string',
[764] Fix | Delete
'context' => array( 'view', 'edit' ),
[765] Fix | Delete
'readonly' => true, // @todo Allow date_reminder to be updated.
[766] Fix | Delete
),
[767] Fix | Delete
'date_reminder_gmt' => array(
[768] Fix | Delete
'description' => __( 'Date after which the user should be reminded of the note, if any (GMT).', 'woocommerce' ),
[769] Fix | Delete
'type' => 'string',
[770] Fix | Delete
'context' => array( 'view', 'edit' ),
[771] Fix | Delete
'readonly' => true,
[772] Fix | Delete
),
[773] Fix | Delete
'is_snoozable' => array(
[774] Fix | Delete
'description' => __( 'Whether or not a user can request to be reminded about the note.', 'woocommerce' ),
[775] Fix | Delete
'type' => 'boolean',
[776] Fix | Delete
'context' => array( 'view', 'edit' ),
[777] Fix | Delete
'readonly' => true,
[778] Fix | Delete
),
[779] Fix | Delete
'actions' => array(
[780] Fix | Delete
'description' => __( 'An array of actions, if any, for the note.', 'woocommerce' ),
[781] Fix | Delete
'type' => 'array',
[782] Fix | Delete
'context' => array( 'view', 'edit' ),
[783] Fix | Delete
'readonly' => true,
[784] Fix | Delete
),
[785] Fix | Delete
'layout' => array(
[786] Fix | Delete
'description' => __( 'The layout of the note (e.g. banner, thumbnail, plain).', 'woocommerce' ),
[787] Fix | Delete
'type' => 'string',
[788] Fix | Delete
'context' => array( 'view', 'edit' ),
[789] Fix | Delete
'readonly' => true,
[790] Fix | Delete
),
[791] Fix | Delete
'image' => array(
[792] Fix | Delete
'description' => __( 'The image of the note, if any.', 'woocommerce' ),
[793] Fix | Delete
'type' => 'string',
[794] Fix | Delete
'context' => array( 'view', 'edit' ),
[795] Fix | Delete
'readonly' => true,
[796] Fix | Delete
),
[797] Fix | Delete
'is_deleted' => array(
[798] Fix | Delete
'description' => __( 'Registers whether the note is deleted or not', 'woocommerce' ),
[799] Fix | Delete
'type' => 'boolean',
[800] Fix | Delete
'context' => array( 'view', 'edit' ),
[801] Fix | Delete
'readonly' => true,
[802] Fix | Delete
),
[803] Fix | Delete
'is_read' => array(
[804] Fix | Delete
'description' => __( 'Registers whether the note is read or not', 'woocommerce' ),
[805] Fix | Delete
'type' => 'boolean',
[806] Fix | Delete
'context' => array( 'view', 'edit' ),
[807] Fix | Delete
'readonly' => true,
[808] Fix | Delete
),
[809] Fix | Delete
),
[810] Fix | Delete
);
[811] Fix | Delete
return $this->add_additional_fields_schema( $schema );
[812] Fix | Delete
}
[813] Fix | Delete
}
[814] Fix | Delete
[815] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function