コード例 #1
0
 public static function define_settings()
 {
     register_setting('tweet_this_options', 'tt_plugin_options', array('TT_Settings', 'validation_helper'));
     //	Global settings applicable to all display modes
     add_settings_section('tweet_this_global', 'Global Settings', array('TT_Settings', 'section_content_helper_global'), TT_FILENAME);
     //	Settings applicable only to box display mode.
     add_settings_section('tweet_this_box', 'Box Display Mode Settings', array('TT_Settings', 'section_content_helper_box'), TT_FILENAME);
     //	Settings applicable only to button link display mode.
     add_settings_section('tweet_this_button_link', 'Button Link Display Mode Settings', array('TT_Settings', 'section_content_helper_button_link'), TT_FILENAME);
     //	Settings applicable only to the shortcode creator dialog box.
     add_settings_section('tweet_this_scc_dialog', 'Shortcode Creator Dialog Settings', array('TT_Settings', 'section_content_helper_scc_dialog'), TT_FILENAME);
     //	Advanced settings / Miscellaneous section
     add_settings_section('tweet_this_advanced', 'Advanced Settings', array('TT_Settings', 'section_content_helper_advanced'), TT_FILENAME);
     //////////////////////////////
     /// Global Settings Fields ///
     //////////////////////////////
     //	Default Twitter Handles
     add_settings_field('tt_default_twitter_handles', 'Default Twitter Handles', array('TT_Settings', 'field_helper_textbox'), TT_FILENAME, 'tweet_this_global', array('name' => 'default_twitter_handles', 'help_text' => 'Comma separated list of "via" Twitter handles you want added to your tweets (leave blank for none). <br />Example: <span class="tt_admin_example">@jt_morris, @DTELinux, @CraigyFerg</span>'));
     //	Default Hidden Hash Tags
     add_settings_field('tt_default_hidden_hashtags', 'Default Hidden Hashtags', array('TT_Settings', 'field_helper_textbox'), TT_FILENAME, 'tweet_this_global', array('name' => 'default_hidden_hashtags', 'help_text' => 'Any hashtags you want added to your message when tweeted, but not displayed in your Tweet This boxes (leave blank for none). <br />Example: <span class="tt_admin_example">#hashtags #rule</span>'));
     //	Default Hidden URLs
     add_settings_field('tt_default_hidden_urls', 'Default Hidden URLs', array('TT_Settings', 'field_helper_textbox'), TT_FILENAME, 'tweet_this_global', array('name' => 'default_hidden_urls', 'help_text' => 'Any URLs you want added to your message when tweeted, but not displayed in your Tweet This boxes (leave blank for none). <br />Example: <span class="tt_admin_example">http://cs.johnmorris.me http://eng.johnmorris.me</span>'));
     //	Twitter Icon
     add_settings_field('tt_twitter_icon', 'Twitter Icon', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_global', array('name' => 'twitter_icon', 'buttons' => TT_Tools::get_twitter_images_as_radio_array(), 'help_text' => 'Choose an icon to display next to the Tweet This link.', 'default' => 'bird1'));
     //	Use Shortlink
     add_settings_field('tt_use_shortlink', 'Use Shortlink?', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_global', array('name' => 'use_shortlink', 'buttons' => array(array('Yes', true), array('No', false)), 'help_text' => 'Your Shortlink Format: <span class="tt_admin_example">' . wp_get_shortlink(TT_Tools::get_id_of_last_post()) . '</span><br /><a href="http://tweetthis.jtmorris.net/posts/beginners-guide-to-wordpress-shortlinks/" target="_blank">Read this article</a> for tips on customizing your shortlinks.'));
     //	Disable URLs in Tweet
     add_settings_field('tt_disable_url', 'Disable URLs', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_global', array('name' => 'disable_url', 'buttons' => array(array('Yes', true), array('No', false)), 'help_text' => 'Choose yes to remove automatically generated URLS from your tweets by default (overridden URLs will still show up).', 'default' => false));
     //	Hide Byline
     add_settings_field('tt_hide_promotional_byline', 'Hide Promotional Byline?', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_global', array('name' => 'hide_promotional_byline', 'id' => 'tt_byline_removal', 'buttons' => array(array('Yes', true), array('No', false)), 'default' => false, 'help_text' => 'Choose "Yes" to remove the "Powered by Tweet This" byline.'));
     //	Display mode
     $box_text = 'Box' . ' (<em><a style="cursor: pointer; text-decoration: underline;" onclick="window.open(\'' . TT_ROOT_URL . 'assets/images/box.jpg\', \'popup\', \'width=491,height=492,scrollbars=no,toolbar=no,menubar=no\')">Click to See Sample</a></em>)';
     $blink_text = 'Button Link' . ' (<em><a style="cursor: pointer;  text-decoration: underline;" onclick="window.open(\'' . TT_ROOT_URL . 'assets/images/button_link.jpg\', \'popup\', \'width=530,height=380,scrollbars=no,toolbar=no,menubar=no\')">Click to See Sample</a></em>)';
     add_settings_field('tt_display_mode', 'Default Display Mode', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_global', array('name' => 'display_mode', 'buttons' => array(array($box_text, 'box'), array($blink_text, 'button_link')), 'help_text' => 'Choose the method for displaying your tweetable content.  Default mode is "Box."', 'default' => 'box'));
     /////////////////////////
     /// Box Mode Settings ///
     /////////////////////////
     //	Theme
     add_settings_field('tt_theme', 'Choose Theme', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_box', array('name' => 'base_theme', 'buttons' => TT_Tools::get_themes_as_radio_array(), 'help_text' => 'Choose the base theme for "Tweet This" boxes. NOTE: The images are not representative of actual size!', 'default' => 'light'));
     /////////////////////////////
     /// Button Link Settings ///
     ////////////////////////////
     //	Include Twitter icon?
     add_settings_field('tt_simple_link_include_icon', 'Include Twitter Icon in Link?', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_button_link', array('name' => 'simple_link_include_icon', 'buttons' => array(array('Yes', true), array('No', false)), 'help_text' => 'Choose yes to include the Twitter icon alongside your link.', 'default' => true));
     /////////////////////////////////////////
     /// Shortcode Creator Dialog Settings ///
     /////////////////////////////////////////
     //	Insert Shortcode Behavior
     add_settings_field('tt_insert_shortcode_behavior', '"Insert Shortcode" Button Behavior', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_scc_dialog', array('name' => 'insert_shortcode_behavior', 'buttons' => array(array('Automatically insert it into WordPress editor', 'auto'), array('Display shortcode for copy and paste', 'manual')), 'help_text' => 'Certain WordPress configurations and plugins interfere with automatic shortcode insertion into your editor. If you receive an error message when clicking "Insert Shortcode" button in Shortcode Creator Dialog, or nothing happens, you will need to switch to copy and paste mode.', 'default' => 'auto'));
     //	Disable Preview?
     add_settings_field('tt_disable_preview', 'Disable Preview?', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_scc_dialog', array('name' => 'disable_preview', 'buttons' => array(array('Yes', true), array('No', false)), 'help_text' => 'Disable the preview of your tweet in the shortcode creator?', 'default' => false));
     //	Disable Character Counter
     add_settings_field('tt_disable_char_count', 'Disable Character Counter?', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_scc_dialog', array('name' => 'disable_char_count', 'buttons' => array(array('Yes', true), array('No', false)), 'help_text' => 'Disable the "characters left" counter?', 'default' => false));
     //	Disable Post URL Options
     add_settings_field('tt_disable_post_url', 'Disable Post URL Options?', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_scc_dialog', array('name' => 'disable_post_url', 'buttons' => array(array('Yes', true), array('No', false)), 'help_text' => 'Disable the post URL options in the shortcode creator?', 'default' => false));
     //	Disable Twitter Handles Options
     add_settings_field('tt_disable_handles', 'Disable Twitter Handle Options?', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_scc_dialog', array('name' => 'disable_handles', 'buttons' => array(array('Yes', true), array('No', false)), 'help_text' => 'Disable the Twitter handle/user options in the shortcode creator?', 'default' => false));
     //	Disable Post URL Options
     add_settings_field('tt_disable_post_url', 'Disable Post URL Options?', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_scc_dialog', array('name' => 'disable_post_url', 'buttons' => array(array('Yes', true), array('No', false)), 'help_text' => 'Disable the post URL options in the shortcode creator?', 'default' => false));
     //	Disable Hidden Content Options
     add_settings_field('tt_disable_hidden', 'Disable Hidden Content Options?', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_scc_dialog', array('name' => 'disable_hidden', 'buttons' => array(array('Yes', true), array('No', false)), 'help_text' => 'Disable the options for hidden content in the shortcode creator?', 'default' => false));
     ///////////////////////
     /// Advanced / Misc ///
     ///////////////////////
     //	Button Text
     add_settings_field('tt_button_text_override', 'Override Button Text', array('TT_Settings', 'field_helper_textbox'), TT_FILENAME, 'tweet_this_advanced', array('name' => 'button_text_override', 'help_text' => 'Override the "Tweet This" text in the call-to-action button/link. Leave blank to use default.'));
     //	Icon Alt Tag
     add_settings_field('tt_icon_alt_text', 'Icon Alt Tag Value', array('TT_Settings', 'field_helper_textbox'), TT_FILENAME, 'tweet_this_advanced', array('name' => 'icon_alt_text', 'help_text' => 'The value of the alt attribute of the Twitter icon &lt;img&gt; tag. Default is none.'));
     //	Alternative Button Placement
     add_settings_field('tt_button_location', 'Editor Button Location', array('TT_Settings', 'field_helper_radio'), TT_FILENAME, 'tweet_this_advanced', array('name' => 'button_location', 'buttons' => array(array('Editor Toolbar, Row #1', 'row1'), array('Editor Toolbar, Row #2', 'row2'), array('Next to Add Media Button', 'media')), 'help_text' => 'By default, this plugin places the shortcode creator dialog button on the top row of the WordPress editor toolbar. Move the button to a different location here.', 'default' => 'row1'));
     //	Template
     add_settings_field('tt_template', 'Tweet Element Template', array('TT_Settings', 'field_helper_textarea'), TT_FILENAME, 'tweet_this_advanced', array('name' => 'template', 'help_text' => 'Customize the order of elements, and their separators, in resulting tweets. Template tags (in the following format "{{ separator {tag_name}}}") are replaced with the corresponding content. Leave blank to use default. Default: "{{{text}}}{{ {hidden_hashtags}}}{{ {hidden_urls}}}{{ {post_url}}}{{ via {twitter_handles}}}"<br /><a href="http://tweetthis.jtmorris.net/posts/introducing-the-tweet-element-template/" target="_blank">Read this article</a> for more detail and examples.', 'style' => 'min-width: 600px;'));
     //	Custom CSS
     add_settings_field('tt_css_override', 'Override CSS', array('TT_Settings', 'field_helper_textarea'), TT_FILENAME, 'tweet_this_advanced', array('name' => 'css_override', 'help_text' => 'Override default CSS rules for "Tweet This".', 'style' => 'min-width: 600px; min-height: 300px;'));
 }