Skip to main content
added 998 characters in body
Source Link

The solution for now is : create a plugin re-creating the shortcode with the current page slug. Naming the page slug like the category slug. And manually add the category to dflip.

Couldn't find better so far.

// Disable direct access
defined('ABSPATH') or die('No script kiddies please!');

// use page slug to call dflip book in same slug dflip_category
add_shortcode('dflip_book_slug', 'shortcode_dflip_book_slug');
function shortcode_dflip_book_slug($atts = array(), $content = '', $tag)
{
    global $post;

    // default parameters (but filtered, only declared ones are passed)
    // $atts = shortcode_atts(array(
    //   'books' => $post->post_name
    // ), $atts, $tag);

    $atts = is_array($atts) ? $atts : array();

    if (array_key_exists('books', $atts)) {
        $atts['books'] = str_replace('%slug%', $post->post_name, $atts['books']);
    } else {
        // par défaut on passe le slug
        $atts['books'] = $post->post_name;
    }

    $atts_str = array();
    foreach ($atts as $key => $value) {
        $atts_str[] = $key . '="' . str_replace('"', '\"', $value) . '"';
    }

    $shortcode = '[dflip ' . implode(' ', $atts_str) . ']' . $content . '[/dflip]';
    return do_shortcode($shortcode);
}

The solution for now is : create a plugin re-creating the shortcode with the current page slug. Naming the page slug like the category slug. And manually add the category to dflip.

Couldn't find better so far.

The solution for now is : create a plugin re-creating the shortcode with the current page slug. Naming the page slug like the category slug. And manually add the category to dflip.

Couldn't find better so far.

// Disable direct access
defined('ABSPATH') or die('No script kiddies please!');

// use page slug to call dflip book in same slug dflip_category
add_shortcode('dflip_book_slug', 'shortcode_dflip_book_slug');
function shortcode_dflip_book_slug($atts = array(), $content = '', $tag)
{
    global $post;

    // default parameters (but filtered, only declared ones are passed)
    // $atts = shortcode_atts(array(
    //   'books' => $post->post_name
    // ), $atts, $tag);

    $atts = is_array($atts) ? $atts : array();

    if (array_key_exists('books', $atts)) {
        $atts['books'] = str_replace('%slug%', $post->post_name, $atts['books']);
    } else {
        // par défaut on passe le slug
        $atts['books'] = $post->post_name;
    }

    $atts_str = array();
    foreach ($atts as $key => $value) {
        $atts_str[] = $key . '="' . str_replace('"', '\"', $value) . '"';
    }

    $shortcode = '[dflip ' . implode(' ', $atts_str) . ']' . $content . '[/dflip]';
    return do_shortcode($shortcode);
}
Source Link

The solution for now is : create a plugin re-creating the shortcode with the current page slug. Naming the page slug like the category slug. And manually add the category to dflip.

Couldn't find better so far.