PHP code example of plugin / pdc-leges

1. Go to this page and download the library: Download plugin/pdc-leges 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/ */

    

plugin / pdc-leges example snippets


'owc/pdc-leges/plugin'

// Default format: '<span>&euro; %s</span>'
add_filter('owc/pdc/leges/shortcode/format', function(string $format){
 return str_replace('span', 'b', $format); // Returns '<b>&euro; %s</b>'
}, 10, 1);

// $output: '<b>&euro; 10,00</b>'
add_filter('owc/pdc/leges/shortcode/after-format', function ($output){
 return str_replace('b', 'span', $output); // Returns: '<span>&euro; 10,00</span>'
}, 10, 1);

add_filter('owc/pdc/leges/metabox/extension-fields/add', function($cmb, $prefix){
 $cmb->add_field([
  'name' => 'Custom field name',
  'desc' => 'Custom field description',
  'id' => sprintf('%s-custom-field-id', $prefix),
  'type' => 'text',
 ]);
}, 10, 2);

add_filter('owc/pdc/leges/rest-api/output/extension-fields/add', function(array $output, WP_Post $post){
 return array_merge($output, [
  'custom-field-id' => get_post_meta($post->ID, '_pdc-lege-custom-field-id', true) ?: null
 ]);
}, 10, 2);

  add_filter('owc/pdc/leges/rest-api/args/allowed-meta-keys', function ($allowed){
   return array_merge($allowed, ['_pdc-lege-custom-field-id']);
 });
sh
GET /wp-json/owc/pdc/v1/leges?limit=5&page=2&meta_key=_pdc-lege-price&meta_value=7.63