This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See: wp-includes/js/api-request.js | |
// Returns a jqXHR object. See: https://api.jquery.com/jQuery.ajax/#jqXHR | |
wp.apiRequest({path: '/namespace/vendor/v1/config'}) | |
.then(configOptions => console.log(configOptions)); | |
// jqXHR object has method then(), but does not have methods catch() or | |
// finally(). Use fail() or always() instead | |
wp.apiRequest({path: '/namespace/vendor/v1/config'}) | |
.done(configOptions => console.log(configOptions)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wp.apiRequest( { path: '/phpbits/test-blocks/v1/user-roles/' } ) | |
.then( | |
( obj ) => { | |
console.log( obj ); | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$job_locations = get_custom_field_config( 'job_location', 'options' ); | |
if ( is_array( $job_locations ) ): | |
?> | |
<select class="" name="search_location" id="search_location"> | |
<option value="" <?php selected( empty( $location ) || ! in_array( $location, $job_locations ) ); ?>><?php _e( 'Any Location' ); ?></option> | |
<?php foreach( $job_locations as $loc_val => $loc_label ): ?> | |
<option value="<?php echo esc_attr( $loc_val ); ?>" <?php selected( $location, $loc_val ); ?>><?php echo esc_attr( $loc_label ); ?></option> | |
<?php endforeach; ?> | |
</select> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Insert an attachment from a URL address. | |
* | |
* @param string $url The URL address. | |
* @param int|null $parent_post_id The parent post ID (Optional). | |
* @return int|false The attachment ID on success. False on failure. | |
*/ | |
function wp_insert_attachment_from_url( $url, $parent_post_id = null ) { |