PHP code example of moxie-lean / wp-endpoints-post
1. Go to this page and download the library: Download moxie-lean/wp-endpoints-post library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
moxie-lean / wp-endpoints-post example snippets
\Lean\Endpoints\View::init();
add_filter( 'ln_endpoints_api_namespace', function( $namespace, $endpoint ) {
return 'my-app';
}, 10, 2 );
add_filter( 'ln_endpoints_api_version', function( $version, $endpoint ) {
return 'v2';
}, 10, 2 );
add_filter( 'ln_endpoints_{endpoint}_query_args', function( $query_args, $request ) {
$query_args['post_type'] = 'page';
return $query_args;
}, 10, 3 );
add_filter( 'ln_endpoints_data_{endpoint}', function( $data, $post_id ) {
$data['content']['title'] = '***' . $data['content']['title'] . '***';
return $data;
}, 10, 3 );
add_filter( 'ln_endpoints_acf', function( $value, $endpoint, $post_id, $field ) {
if ( 'image' === $field['type'] ) {
return 'https://upload.wikimedia.org/wikipedia/commons/1/1b/Nice-night-view-with-blurred-cars_1200x900.jpg';
}
return $value;
}, 10, 4 );
add_filter( 'ln_endpoints_acf_image_size', function( $size, $endpoint, $post_id, $field, $sub_field ) {
if ( 'logo' === $field['name'] ) {
return 'very_small';
}
return $size;
}, 10, 4 );
add_filter( 'ln_endpoints_acf_repeater_as_array', function( $as_array, $endpoint, $post_id, $field ) {
$post = get_post( $post_id );
return 'training' === $post->page_template && 'cta' === $field['name'] ? false : $as_array;
}, 10, 4 );
ln_endpoints_acf_repeater_as_array