1

問題があります。何が間違っているのか理解できません..

WordPressの他の機能の機能の値を取得したい..

このコードは、コードの一部を置き換えます..

引数変数 words の値を取得してから ($attr['words'] に移動する必要があります)、他の関数 (new_quote) を使用したいと考えています。

    <?php
    /*
    * Plugin Name: Random Quotes
    */

    function random_quote($atts) {
        extract( shortcode_atts( array(
        'path' => plugin_dir_path(__FILE__).'quotes.txt',// default, if not set
        'label_new' => 'New Quote',
        'words' => 'no'   // yes or no 
        ), $atts ) );

        $temp = $attr['words']; // no
        ...

    }

    add_shortcode('randomquotes','random_quote');


    function new_quote(){
    global $temp;  // NULL
    /*
    global $attr;
    $temp = $attr['words']; // again NULL
    */
        ...

        if($temp == "no") {
        ...
        }
    }

   ...

?>

私は何を間違っていますか?たぶん、この変数の値を取得できませんか?

4

1 に答える 1