it-swarm.com.de

plugin-Shortcode-Funktion ändern

ich verwende ein Plugin , das diesen Code enthält, und ich möchte den css- und js- und template.php-Speicherort in meinem Vorlagenverzeichnis ändern, anstatt das Plugin zu verwenden, ohne die Plugin-Dateien zu bearbeiten

public function shortcode($atts, $content = NULL) {

    global $post, $wpdb;

    STATIC $i = 1;



    $timelinr_options = get_option('timelinr_general_options');

    $desing_options = get_option('timelinr_desing_options');

    $pairs = array(

            'orientation' => $timelinr_options['orientation'],

            'startat' => intval($timelinr_options['startat']),

            'arrowkeys' => $timelinr_options['arrowkeys'],

            'autoplay' => $timelinr_options['autoplay'],

            'autoplaydirection' => $timelinr_options['autoplaydirection'],

            'autoplaypause' => $timelinr_options['autoplaypause'],

            'order' => $timelinr_options['order'],

            'containerdiv' => 'timelinr-'.$i,

            'category' => '',

            'dateformat' => $desing_options['dateformat'],

    );

    $atts = shortcode_atts($pairs, $atts );



    if ( strcmp ( $atts['orientation'] , 'horizontal' ) == 0){

        wp_enqueue_style('timelinr-style', JQTL_BASE_URL . '/assets/css/style.css', '', JQTL_CURRENT_VERSION );

    } elseif ( strcmp ( $atts['orientation'] , 'vertical' ) == 0) {

        wp_enqueue_style('timelinr-style_v', JQTL_BASE_URL . '/assets/css/style_v.css', '', JQTL_CURRENT_VERSION );

    }



    ob_start();

    include (JQTL_BASE_PATH . '/includes/template.php');

    $out = ob_get_contents();

    ob_end_clean();



    $i++;

    return $out;

}
1
Amro Shalaby

sie können den Shortcode wie folgt überschreiben:

add_action("init", function () {


    remove_shortcode("timelinr");

    add_shortcode("timelinr", function ($atts, $content) {

        // call the shortcode of jqueryTimelinrLoad
        $result = $GLOBALS["jqueryTimelinrLoad"]->shortcode($atts, $content);

        // dequeue style
        wp_dequeue_style("timelinr-style");

        // enqueue your style
        wp_enqueue_style("timelinr-style2", "new.css");

        // result of the shortcode
        return $result;
    });

});
3
mmm