错误的WordPress主题选项页面PHP - 卡住了

时间:2012-04-24 06:11:03

标签: php wordpress themes wordpress-theming

好的......我一直在看这件事,我不得不承认失败。

我正在拼凑一个WordPress主题的选项页面,我正在获取

“警告:call_user_func_array()[function.call-user-func-array]:第一个参数应该是一个有效的回调函数,在/ home / bahia001 / public_html / test / wp-includes /中给出'flaunt_one_theme_options'第405行上的plugin.php“错误。

我知道这可能是由于我曾经将这些代码片段放在一起的错误命名法,但我需要一些指导。我是PHP的新手。


这是我的代码:

<?php
//Theme Options 
function my_admin_scripts(){
wp_enqueue_script('media-upload');
}

if (isset($_GET['page']) && $_GET['page'] == 'folio-themes-setup') {
add_action('admin_print_scripts', 'my_admin_scripts');

add_action('admin_print_styles', 'my_admin_styles');

}

add_action('admin_menu', 'flaunt_one_create_menu');
function flaunt_one_create_menu() {
add_menu_page('Flaunt One Options', 'Flaunt One Options', 'administrator','folio-themes-setup', 'flaunt_one_theme_options',get_bloginfo('stylesheet_directory')."/images/flaunt16.png",63);
add_action( 'admin_init', 'register_mysettings' );
}
function register_mysettings() {
register_setting( 'flaunt-one-settings-group', 'flaunt_one_logo');
register_setting( 'flaunt-one-settings-group', 'flaunt_one_favico');
}
function sw_settings_page() {
?>





<div class="wrap">
    <?php screen_icon(); echo "<h2>" . get_current_theme() . __( 'Options', 'flaunt_one' ) . "</h2>"; ?>    

<div id="flaunt-options" style="width:800px; float:left;">

    <?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
    <div class="updated fade"><p><strong><?php _e( 'Options saved', 'flaunt_one' ); ?></strong></p></div>
    <?php endif; ?>

    <form method="post" action="options.php">
        <?php settings_fields( 'flaunt_one_options' ); ?>
        <?php $options = get_option( 'flaunt_one_theme_options' ); ?>

        <table class="form-table">


             <tr valign="top">
    <th scope="row"><h3>Style Options:</h3></th>
    <td></td>
    </tr>

    <tr valign="top">
    <th scope="row">Logo:</th>
    <td><input size="53" type="text" name="sw_logo" value="<?php echo get_option('flaunt_one_logo'); ?>" /><input class="upload_image_button" type="button" value="Upload" />
    </td>
    </tr>
    <? if(get_option('flaunt_one_logo')){ ?>
          <tr valign="top">
          <th scope="row"></th>
          <td><img src="<?php echo get_option('flaunt_one_logo'); ?>" alt="" /></td>
          </tr>

    <? } ?>
    <tr valign="top">
    <th scope="row">Favicon:</th>
    <td><input size="53" type="text" name="favico" value="<?php echo get_option('flaunt_one_favico'); ?>" /><input class="upload_image_button"  type="button" value="Upload" /></td>
    </tr>
        </table>

    <h3>Social Media Icons:</h3>
    <p><?php _e( 'These options will let you setup the social icons at the top of the theme. You can enter the URLs of your profiles to have the icons show up.', 'flaunt_one' ); ?></p>

        <table class="form-table">
            <?php
            /**
             * Facebook Icon
             */
            ?>
            <tr valign="top"><th scope="row"><?php _e( 'Enter your Facebook URL', 'flaunt_one' ); ?></th>
                <td>
                    <input id="flaunt_one_theme_options[facebookurl]" class="regular-text" type="text" name="flaunt_one_theme_options[facebookurl]" value="<?php esc_attr_e( $options['facebookurl'] ); ?>" />
                    <label class="description" for="flaunt_one_theme_options[facebookurl]"><?php _e( 'Leave blank to hide Facebook Icon', 'flaunt_one' ); ?></label>
                </td>
            </tr>

            <?php
            /**
             * Twitter URL
             */
            ?>
            <tr valign="top"><th scope="row"><?php _e( 'Enter your Twitter URL', 'flaunt_one' ); ?></th>
                <td>
                    <input id="flaunt_one_theme_options[twitterurl]" class="regular-text" type="text" name="flaunt_one_theme_options[twitterurl]" value="<?php esc_attr_e( $options['twitterurl'] ); ?>" />
                    <label class="description" for="flaunt_one_theme_options[twitterurl]"><?php _e( 'Leave blank to hide Twitter Icon', 'flaunt_one' ); ?></label>
                </td>
            </tr>

            <?php
            /**
             * Google+ URL
             */
            ?>
            <tr valign="top"><th scope="row"><?php _e( 'Enter your Google+ URL', 'flaunt_one' ); ?></th>
                <td>
                    <input id="flaunt_one_theme_options[googleplusurl]" class="regular-text" type="text" name="flaunt_one_theme_options[googleplusurl]" value="<?php esc_attr_e( $options['googleplusurl'] ); ?>" />
                    <label class="description" for="flaunt_one_theme_options[googleplusurl]"><?php _e( 'Leave blank to hide Google+ Icon', 'flaunt_one' ); ?></label>
                </td>
            </tr>

                            <?php
            /**
             * Pinterest URL
             */
            ?>
            <tr valign="top"><th scope="row"><?php _e( 'Enter your Pinterest URL', 'flaunt_one' ); ?></th>
                <td>
                    <input id="flaunt_one_theme_options[pinteresturl]" class="regular-text" type="text" name="flaunt_one_theme_options[pinteresturl]" value="<?php esc_attr_e( $options['pinteresturl'] ); ?>" />
                    <label class="description" for="flaunt_one_theme_options[pinteresturl]"><?php _e( 'Leave blank to hide Pinterest Icon', 'flaunt_one' ); ?></label>
                </td>
            </tr>           

            <?php
            /**
             * RSS Icon
             */
            ?>
            <tr valign="top"><th scope="row"><?php _e( 'Enter your RSS URL', 'flaunt_one' ); ?></th>
                <td>
                    <input id="flaunt_one_theme_options[rssurl]" class="regular-text" type="text" name="flaunt_one_theme_options[rssurl]" value="<?php esc_attr_e( $options['rssurl'] ); ?>" />
                    <label class="description" for="flaunt_one_theme_options[rssurl]"><?php _e( 'Enter your Feedburner url. If you dont have one use "http://yoursitename.com/feed/"', 'flaunt_one' ); ?></label>
                </td>
            </tr>

        </table>

        <p class="submit">
            <input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'flaunt_one' ); ?>" />
        </p>
    </form>
</div>

    <!-- End Social Share Buttons -->       

    <!-- Sharing Column -->
<div id="share-column" style="float:right;">

<!-- Begin MailChimp Signup Form -->
<div id="flaunt-mc-signup">
    <link href="http://cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
    <div id="mc_embed_signup">
    <form action="http://flauntyoursite.us2.list-manage.com/subscribe/post?u=9d1d3626942e4f97eb4bb6699&amp;id=b85f19e2d3" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
    <label for="mce-EMAIL">Subscribe to our mailing list</label>
    <input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
        <div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button-primary"></div>
    </form>
    </div>
</div>
<!--End mc_embed_signup-->


<!-- Begin Sharing Section -->
<div class="flaunt-share">
<p>Could you do me a <strong>huge</strong> favor and share this plugin with others. Thank you so much!</p>                          
                        <ul style="list-style:none;">
                                    <li><?php echo flaunt_like_facebook(); ?>
                                        <?php
    }
    //Render Facebook Like button
    //http://developers.facebook.com/docs/reference/plugins/like/
    //TODO Not using since correct image isn't coming up for now
    function flaunt_like_facebook() {
?>

<div id="fb-root">
</div>
    <script>(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=237425446277620";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="http://flauntyoursite.com" data-send="false" data-layout="button_count" data-width="150" data-show-faces="false"></div>

                                    </li>


                                    <li><?php echo flaunt_share_twitter(); ?>
                                        <?     php
     }
     //Render Twitter button
     //https://twitter.com/about/resources/buttons
     function flaunt_share_twitter() {
 ?>
 <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://flauntyoursite.com/" data-text="Flaunt Your Site - We Get Photographers Noticed!" alt="Tweet this!">Tweet</a>
 <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s) [0];if(!d.getElementById(id)) {js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>  

                                    </li>


                                    <li><?php echo flaunt_share_google_plus(); ?>
                                        <?php
     }
     //Render Google +1 button
     //http://www.google.com/intl/en/webmasters/+1/button/index.html
     function flaunt_share_google_plus() {
 ?>

 <!-- Place this tag where you want the +1 button to render -->
 <div class="g-plusone" data-size="medium" data-href="http://flauntyoursite.com/">
 </div>
 <!-- Place this render call where appropriate -->
 <script type="text/javascript">
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>
                                    </li>


                                    <li>(Or <a href="http://wordpress.org/extend/plugins/#/" target="_blank">rate it on WordPress</a>)      </li>
                        </ul>

</div><!-- End Sharing Section -->
    </div>  <!-- End Sharing Column -->
    </div> <!-- End Wrapper -->

    <?php
    }

    /**
    * Sanitize and validate input. Accepts an array, return a sanitized array.
    */
    function flaunt_one_options_validate( $input ) {

// Our text option must be safe text with no HTML tags
$input['twitterurl'] = wp_filter_nohtml_kses( $input['twitterurl'] );
$input['facebookurl'] = wp_filter_nohtml_kses( $input['facebookurl'] );
$input['googleplusurl'] = wp_filter_nohtml_kses( $input['googleplusurl'] );
    $input['pinteresturl'] = wp_filter_nohtml_kses( $input['pinteresturl'] );   
$input['feedurl'] = wp_filter_nohtml_kses( $input['feedurl'] );


// Encode URLs
$input['twitterurl'] = esc_url_raw( $input['twitterurl'] );
$input['facebookurl'] = esc_url_raw( $input['facebookurl'] );
$input['googleplusurl'] = esc_url_raw( $input['googleplusurl'] );
$input['pinteresturl'] = esc_url_raw( $input['pinteresturl'] );
$input['feedurl'] = esc_url_raw( $input['feedurl'] );
return $input;
    }

1 个答案:

答案 0 :(得分:2)

看起来错误正在发生,因为当您在代码末尾插入 flaunt_one_options_validate 函数时,该函数无法通过 $ input <接收您要发送的内容/ strong>变量。

function flaunt_one_options_validate( $input ) 

在页面上,我必须声明输入变量并具有一些值。这需要在调用函数之前以正确的格式(强或数字等)可读。

首先尝试使用静态值测试函数,以便您知道该函数正在运行。然后尝试使变量动态化。

希望这有帮助,一旦你完成了这个更新这篇文章。

瑞克