[wp-hackers] Theme options panel questions - Add social bookmarking

Chris Jean gaarai at gaarai.com
Tue Feb 9 15:21:18 UTC 2010


For your single.php code, you have two main issues:

   1. All of your begin PHP blocks are "<?" rather than "<?php". While
      this may work on some systems, it will fail on others. So, always
      use "<?php" rather than "<?".
   2. You are referencing variables that don't exist. For example, there
      is not a $mytheme_facebook_enable variable. Instead, you should be
      checking get_option('mytheme_facebook_enable') as the data is
      stored in the options system.

Logically, your functions.php code is fine. My main suggestion is that 
you change get_settings to get_option as the get_settings function is 
deprecated. get_option functions in the same was as get_settings, so 
only the function name needs to be changed.

Going beyond the project at hand, I recommend the following to improve 
your development practices:

    * Learn some coding practice fundamentals. Using proper indenting
      and a clean, consistent coding style will make your code easier to
      read and debug. I recommend reading the following:
          o http://codex.wordpress.org/WordPress_Coding_Standards
          o http://en.wikipedia.org/wiki/Indent_style
    * Avoid deprecated functions: http://en.wikipedia.org/wiki/Deprecation
    * Enable WP_DEBUG in your wp-config.php as this will show you
      warnings about non-existent variables (your single.php variables),
      deprecated functions (the get_settings calls in functions.php),
      and unchecked array indexes (this can be useful to find out when
      you have a typo in your array references).
      http://codex.wordpress.org/Editing_wp-config.php#Debug

Chris Jean
Coder for http://ithemes.com/
http://gaarai.com/
@chrisjean


On 02/09/2010 02:18 AM, Jeremy Herve wrote:
> Hi there!
>
> I am having a few issues figuring this out by myself, and I did not
> receive help on the WordPress forums, so I now ask the question
> directly to the pros! :)
>
> I am trying to develop a theme with an options panel allowing the user
> to choose which social bookmarking websites he would like to have
> displayed on single articles pages thanks to checkboxes.
>
> Here is what I have done so far:
>
> In my functions.php
> http://pastebin.com/f37ea5d17
>
> In single.php
> http://pastebin.com/f3d9d923d
>
> But I must miss something: everything is displayed in single.php,
> checkboxes activated or not; and when I try to modify checkboxes in
> the admin options panel, I get an error message:
> "You do not have sufficient permissions to access this page."
>
> Do you have any idea how to work this out?
>
> Thanks for your help!
>
> Jeremy Herve
> http://twitter.com/jeherve
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>    


More information about the wp-hackers mailing list