GPAISRSettings

GPAISRSettings class.

Defined (1)

The class is defined in the following location(s).

/class.settings.php  
  1. class GPAISRSettings { 
  2. /** 
  3. * pagehook 
  4. * will be set in the menu-function 
  5. * (default value: '') 
  6. * @var string 
  7. * @access private 
  8. * @since 0.7 
  9. */ 
  10. private $_pagehook = ''; 
  11.  
  12.  
  13. /** 
  14. * @var string|null 
  15. * @since 0.7 
  16. */ 
  17. private $_plugin_file = null; 
  18.  
  19.  
  20. /** 
  21. * __construct function. 
  22. * @access public 
  23. * @since 0.7 
  24. * @param $plugin_file 
  25. * @return \GPAISRSettings 
  26. */ 
  27. function __construct( $plugin_file ) { 
  28.  
  29. $this->_plugin_file = $plugin_file; 
  30.  
  31. // Creates the menu 
  32. add_action( 'admin_menu', array( &$this, 'menu' ) ); 
  33.  
  34. // Creates the settings (and the settings page) 
  35. add_action( 'admin_init', array( &$this, 'settings' ) ); 
  36.  
  37. add_filter( 'plugin_action_links_' . plugin_basename( $this->_plugin_file ), array( &$this, 'plugin_action_links' ) ); 
  38.  
  39.  
  40.  
  41. /** 
  42. * scripts function. 
  43. * adds the scripts which are important for add_metabox 
  44. * @access public 
  45. * @return void 
  46. * @since 0.7 
  47. */ 
  48. public function scripts() { 
  49. wp_enqueue_script( 'common' ); 
  50. wp_enqueue_script( 'wp-lists' ); 
  51. wp_enqueue_script( 'postbox' ); 
  52.  
  53.  
  54. /** 
  55. * menu function. 
  56. * will add the menu in the WordPress backend 
  57. * @access public 
  58. * @return void 
  59. * @since 0.7 
  60. */ 
  61. public function menu() { 
  62. $this->_pagehook = add_options_page( __( 'Google+ Author Free', 'gpaisr' ), __( 'Google+ Author Free', 'gpaisr' ), 'administrator', 'gpaisr', array( $this, 'settings_page' ) ); 
  63. add_action( 'load-' . $this->_pagehook, array( &$this, 'scripts' ) ); 
  64.  
  65.  
  66. /** 
  67. * settings_page function. 
  68. * creates the settings page content and some metaboxes 
  69. * @access public 
  70. * @return void 
  71. * @since 0.7 
  72. */ 
  73. public function settings_page() { 
  74. // add meteabox "General" 
  75. add_meta_box( 'gpaisr-contentbox-1', __( 'General' ), array( &$this, 'metabox_general' ), $this->_pagehook, 'normal', 'core' ); 
  76.  
  77. // add metabox "howto" 
  78. add_meta_box( 'gpaisr-contentbox-2', __( 'What to do', 'gpaisr' ), array( &$this, 'metabox_howto' ), $this->_pagehook, 'normal', 'low' ); 
  79.  
  80. // add metabox "settings 
  81. add_meta_box( 'gpaisr-contentbox-3', __( 'Settings' ), array( &$this, 'metabox_settings' ), $this->_pagehook, 'normal', 'low' ); 
  82.  
  83. // add metabox "about" 
  84. add_meta_box( 'gpaisr-contentbox-4', __( 'About', 'gpaisr' ), array( &$this, 'metabox_about' ), $this->_pagehook, 'side', 'default' ); 
  85.  
  86. // add metabox "share" 
  87. add_meta_box( 'gpaisr-contentbox-5', __( 'Share', 'gpaisr' ), array( &$this, 'metabox_share' ), $this->_pagehook, 'side', 'default' ); 
  88.  
  89. add_meta_box( 'gpaisr-contentbox-7', __( 'Discover', 'gpaisr' ), array( &$this, 'metabox_discover' ), $this->_pagehook, 'side', 'default' ); 
  90.  
  91. // add the metabox "links" 
  92. add_meta_box( 'gpaisr-contentbox-6', __( 'Helpful links', 'gpaisr' ), array( &$this, 'metabox_links' ), $this->_pagehook, 'side', 'default' ); 
  93.  
  94.  
  95. global $screen_layout_columns; 
  96.  
  97. $lastPostPermalink = get_bloginfo( 'url' ); 
  98. query_posts( 'showposts=1&post_status=publish' ); 
  99. while ( have_posts() ) : the_post(); 
  100. $lastPostPermalink = get_permalink(); 
  101. endwhile; 
  102.  
  103. include_once( 'page.settings.php' ); 
  104.  
  105.  
  106. /** 
  107. * metabox_general function. 
  108. * creates the content for the general metabox 
  109. * @access public 
  110. * @param mixed $data 
  111. * @return void 
  112. * @since 0.6 
  113. */ 
  114. public function metabox_general( $data ) { 
  115. echo '<p>' . __( 'This plugin will replace your author link in your template with your Google+ Profile link to make sure that the picture will be shown at the search results.', 'gpaisr' ) . '</p>'; 
  116. echo '<p>' . __( 'Alternatively the link can be included after the content if your template does not show the author link.', 'gpaisr' ) . '</p>'; 
  117.  
  118. echo '<p><strong>' . __( 'Please note:', 'gpaisr' ) . '</strong> ' . __( 'Google says that there is no guarantee that a Rich Snippet will be shown for your page on actual search results.', 'gpaisr' ) . ' <a href="http://support.google.com/webmasters/bin/answer.py?hl=en&answer=1306778&ctx=cb&src=cb&cbid=-1n2ig3z0a1yr8&cbrank=0" target="_blank">' . __( 'Please click here for more information', 'gpaisr' ) . '</a></p>'; 
  119.  
  120.  
  121. /** 
  122. * metabox_howto function. 
  123. * creates the content for the howto-metabox 
  124. * @access public 
  125. * @param mixed $data 
  126. * @return void 
  127. * @since 0.6 
  128. */ 
  129. public function metabox_howto( $data ) { 
  130. ?> 
  131.  
  132. <h4><?php echo __( 'A) Set up authorship by linking your content to your Google+ profile', 'gpaisr' ); ?></h4> 
  133.  
  134. <ol id="gplisting"> 
  135.  
  136. <li><?php echo sprintf( __( 'Follow this link to open your Google+ profile: %s', 'gpaisr' ), '<a href="http://plus.google.com/me" target="_blank">http://plus.google.com/me</a>' ); ?></li> 
  137.  
  138. <li><?php echo __( 'Copy your Profile-URL from the address bar to clipboard (see picture below):', 'gpaisr' ); ?> 
  139. <br /> 
  140. <img src="<?php echo plugins_url( 'images/gplus-profile.jpg', __FILE__ ); ?>" alt="" style="border: 1px solid black;" /> 
  141. </li> 
  142.  
  143. <li><?php echo __( 'Go to your Wordpress Admin Panel and click Users -> Your Profile. Paste the above mentioned URL to the field where it says "Google+".', 'gpaisr' ); ?> 
  144. <br /> 
  145. <img src="<?php echo plugins_url( 'images/gplus-update-profile.jpg', __FILE__ ); ?>" alt="" style="border: 1px solid black;" /> 
  146. </li> 
  147.  
  148. <li><?php echo __( 'Click Update Profile.', 'gpaisr' ); ?></li> 
  149.  
  150. <li><?php echo __( 'Repeat the above steps with all the other Wordpress authors on your blog.', 'gpaisr' ); ?></li> 
  151.  
  152. </ol> 
  153.  
  154. <br /> 
  155. <h4><?php echo __( 'B) Add a reciprocal link back from your profile to the site you just updated', 'gpaisr' ); ?></h4> 
  156.  
  157. <ol id="gplisting"> 
  158.  
  159. <li><?php echo sprintf( __( 'Follow this link to edit the Contributor To section: %s', 'gpaisr' ), '<a href="http://plus.google.com/me/about/edit/co" target="_blank">http://plus.google.com/me/about/edit/co</a>' ); ?></li> 
  160.  
  161.  
  162. <li><?php echo sprintf( __( 'A dialog will appear. Scroll down to the "Contributor to" section. Click "Add custom link" and enter your website URL: %s', 'gpaisr' ), site_url() ); ?></li> 
  163.  
  164. <li><?php echo sprintf( __( 'Optional: For the label you can use your website title: %s', 'gpaisr' ), get_bloginfo( 'name' ) ); ?></li> 
  165.  
  166. <li><?php echo __( 'If you want, click the drop-down list to specify who can see the link.', 'gpaisr' ); ?></li> 
  167.  
  168. <li><?php echo __( 'Click Save.', 'gpaisr' ); ?></li> 
  169.  
  170. <li><?php echo __( 'Tell your authors that they should also do step B.', 'gpaisr' ); ?></li> 
  171.  
  172. </ol> 
  173.  
  174. <br /> 
  175. <h4><?php echo __( 'C) Test', 'gpaisr' ); ?></h4> 
  176.  
  177. <ol id="gplisting"> 
  178.  
  179. <li><?php echo __( 'To see what author data Google can extract from your page, use the Rich Snippet Testing Tool.', 'gpaisr' ); ?></li> 
  180.  
  181. </ol> 
  182.  
  183. <?php 
  184.  
  185.  
  186. /** 
  187. * metabox_settings function. 
  188. * creates the content for the settings metabox 
  189. * @access public 
  190. * @param mixed $data 
  191. * @return void 
  192. * @since 0.6 
  193. */ 
  194. public function metabox_settings( $data ) { 
  195. ?> 
  196. <form action="options.php" method="post"> 
  197.  
  198. <?php settings_fields( 'gpaisr_options_group' ); ?> 
  199.  
  200. <?php 
  201. do_settings_sections( 'gpaisr' ); 
  202. wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); 
  203. wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); 
  204. ?> 
  205.  
  206. <p class="submit" style="float:left;"> 
  207. <input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes' ); ?>" /> 
  208. </p> 
  209. </form> 
  210. <form action="http://www.google.com/webmasters/tools/richsnippets" method="get" target="_blank"> 
  211. <input type="hidden" value="<?php echo $data['lastPostPermalink']; ?>" name="url" /> 
  212.  
  213. <p class="submit"> 
  214. <input name="Submit" type="submit" class="button-primary" value="<?php echo __( 'Test the latest post or page.', 'gpaisr' ); ?>" /> 
  215. </p> 
  216. <br class="clear" /> 
  217. </form> 
  218. <?php 
  219.  
  220.  
  221. /** 
  222. * Shows the "about" metabox 
  223. * @since 0.7 
  224. */ 
  225. public function metabox_about() { 
  226. ?> 
  227. <a href="http://bit.ly/TO0Z5w" target="_blank"><img src="https://wpbuddy.libra.uberspace.de/secure/wp-buddy-logo.png" alt="WPBuddy Logo" /></a><?php 
  228.  
  229. /** 
  230. * metabox_share function. 
  231. * creates the content for the sare side-metabox 
  232. * @access public 
  233. * @param mixed $data 
  234. * @return void 
  235. * @since 0.6 
  236. */ 
  237. public function metabox_share( $data ) { 
  238. ?> 
  239.  
  240. <!-- Google+ Button --> 
  241. <p> 
  242. <div class="g-plusone" data-size="medium" data-annotation="inline" data-href="http://wp-buddy.com/products/plugins/google-authorship-wordpress-plugin/"></div></p> 
  243.  
  244. <!-- Facebook button --> 
  245. <p> 
  246. <div class="fb-like" data-href="http://wp-buddy.com/products/plugins/google-authorship-wordpress-plugin/" data-send="false" data-layout="button_count" data-width="150" data-show-faces="false"></div></p> 
  247.  
  248. <!-- Twitter-Button --> 
  249. <p> 
  250. <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://wp-buddy.com/products/plugins/google-authorship-wordpress-plugin/" data-via="floriansimeth">Tweet</a> 
  251. </p> 
  252. <?php 
  253.  
  254.  
  255. /** 
  256. * metabox_discover function. 
  257. * creates a metabox with the affiliate link to pro-version 
  258. * @access public 
  259. * @param mixed $data 
  260. * @return void 
  261. * @since 0.6 
  262. */ 
  263. public function metabox_discover( $data ) { 
  264. ?> 
  265. <a href="http://bit.ly/Wn88bZ" target="_blank"><img src="https://wpbuddy.libra.uberspace.de/secure/google-author-pro.jpg" border="0" alt="" /></a> 
  266. <?php 
  267.  
  268.  
  269. /** 
  270. * settings function. 
  271. * creates the settings-fields in the settings-metabox 
  272. * @access public 
  273. * @return void 
  274. * @since 0.6 
  275. */ 
  276. function settings() { 
  277.  
  278. register_setting( 'gpaisr_options_group', 'gpaisr' ); 
  279.  
  280. add_settings_section( 'gpaisr_section_text', '', array( $this, 'sectionText' ), 'gpaisr' ); 
  281.  
  282. add_settings_field( 'gpaisr_into_header', __( 'Add to the header', 'gpaisr' ), array( $this, 'field_into_header' ), 'gpaisr', 'gpaisr_section_text' ); 
  283.  
  284. add_settings_field( 'gpaisr_replace_author_link', __( 'Replace author link with the Google Profile URL?', 'gpaisr' ), array( $this, 'field_replacement' ), 'gpaisr', 'gpaisr_section_text' ); 
  285.  
  286. add_settings_field( 'gpaisr_hide_author_link_in_content', __( 'Show or hide the link in the content-section?', 'gpaisr' ), array( $this, 'field_hide' ), 'gpaisr', 'gpaisr_section_text' ); 
  287.  
  288. add_settings_field( 'gpaisr_open_in_new_window', __( 'Open the link in a new window?', 'gpaisr' ), array( $this, 'field_new_window' ), 'gpaisr', 'gpaisr_section_text' ); 
  289.  
  290. add_settings_field( 'gpaisr_rss', __( 'Display in Feed?', 'gpaisr' ), array( $this, 'field_rss' ), 'gpaisr', 'gpaisr_section_text' ); 
  291.  
  292. add_settings_field( 'gpaisr_link_text', __( 'Link text', 'gpaisr' ), array( $this, 'field_link_text' ), 'gpaisr', 'gpaisr_section_text' ); 
  293.  
  294. add_settings_field( 'gpaisr_affiliate', '', array( $this, 'field_affiliate' ), 'gpaisr', 'gpaisr_section_text' ); 
  295.  
  296.  
  297.  
  298. /** 
  299. * sectionText function. 
  300. * this is a text-section 
  301. * @access public 
  302. * @return void 
  303. * @since 0.6 
  304. */ 
  305. function sectionText() { 
  306. echo '<p>' . __( 'Not every theme shows the Author-Link right beside a page or an article. In this case activate the link to be included after the content.', 'gpaisr' ); 
  307.  
  308.  
  309. function field_into_header() { 
  310. $options = get_option( 'gpaisr' ); 
  311. if ( ! isset( $options['into_header'] ) ) { 
  312. $options['into_header'] = 0; 
  313. echo "<input " . checked( intval( $options['into_header'] ), 1, false ) . " id='gpaisr_into_header' name='gpaisr[into_header]' type='checkbox' value='1' />"; 
  314. echo ' <small>' . __( '(Recommended. Not visible to the user.)', 'gpaisr' ) . '</small>'; 
  315.  
  316. ?> 
  317. <script type="text/javascript"> 
  318. /* <![CDATA[ */ 
  319. jQuery(document).ready(function () { 
  320. if (jQuery('#gpaisr_into_header').is(':checked')) { 
  321. jQuery('#gpaisr_into_header').closest('table').find('tr:gt(0)').hide(); 
  322.  
  323. jQuery('#gpaisr_into_header').on('click', function() { 
  324. if (jQuery(this).is(':checked')) { 
  325. jQuery(this).closest('table').find('tr:gt(0)').hide(); 
  326. } else { 
  327. jQuery(this).closest('table').find('tr:gt(0)').show(); 
  328. }); 
  329. }); 
  330. /* ]]> */ 
  331. </script> 
  332. <?php 
  333.  
  334. /** 
  335. * field_replacement function. 
  336. * shows the replacement-settings field 
  337. * @access public 
  338. * @return void 
  339. * @since 0.6 
  340. */ 
  341. function field_replacement() { 
  342. $options = get_option( 'gpaisr' ); 
  343. if ( ! isset( $options['replacement'] ) ) { 
  344. $options['replacement'] = 0; 
  345. echo "<input " . ( ( $options['replacement'] == 1 ) ? 'checked="checked"' : '' ) . " id='gpaisr_replace_author_link_1' name='gpaisr[replacement]' type='radio' value='1' /> " . __( 'Yes' ) . ' <small>' . __( '(Please note: Some themes does not support this.)', 'gpaisr' ) . '</small>'; 
  346. echo "<br /><input " . ( ( empty( $options['replacement'] ) ) ? 'checked="checked"' : '' ) . " id='gpaisr_replace_author_link_0' name='gpaisr[replacement]' type='radio' value='0' /> " . __( 'No' ) . '. <small>' . __( 'Instead show it in the content-area (see below)', 'gpaisr' ) . '</small>'; 
  347.  
  348.  
  349. /** 
  350. * field_hide function. 
  351. * displays the show or hide settings field 
  352. * @access public 
  353. * @return void 
  354. * @since 0.6 
  355. */ 
  356. function field_hide() { 
  357. $options = get_option( 'gpaisr' ); 
  358. if ( ! isset( $options['hide'] ) ) { 
  359. $options['hide'] = 0; 
  360. echo "<input " . ( ( $options['hide'] == 1 ) ? 'checked="checked"' : '' ) . " id='gpaisr_replace_hide_1' name='gpaisr[hide]' type='radio' value='1' /> " . __( 'Hide' ) . ' <small>' . __( '(Please not that Google does not like hidden links)', 'gpaisr' ) . '</small>'; 
  361. echo "<br /><input " . ( ( empty( $options['hide'] ) ) ? 'checked="checked"' : '' ) . " id='gpaisr_replace_hide_0' name='gpaisr[hide]' type='radio' value='0' /> " . __( 'Show' ); 
  362.  
  363.  
  364. /** 
  365. * field_new_window function. 
  366. * shows the new window settings field 
  367. * @access public 
  368. * @return void 
  369. * @since 0.6 
  370. */ 
  371. function field_new_window() { 
  372. $options = get_option( 'gpaisr' ); 
  373. echo "<input " . ( ( isset( $options['new_window'] ) && $options['new_window'] == 1 ) ? 'checked="checked"' : '' ) . " id='gpaisr_new_window' name='gpaisr[new_window]' type='checkbox' value='1' />"; 
  374.  
  375.  
  376. /** 
  377. * field_rss function. 
  378. * shows the "no rss" settings field 
  379. * @access public 
  380. * @return void 
  381. * @since 0.6 
  382. */ 
  383. function field_rss() { 
  384. $options = get_option( 'gpaisr' ); 
  385. echo "<input " . ( ( isset( $options['in_feed'] ) && $options['in_feed'] == 1 ) ? 'checked="checked"' : '' ) . " id='gpaisr_in_feed' name='gpaisr[in_feed]' type='checkbox' value='1' /> <small>(" . __( 'Check this if you want to display the Google+ Link inside the feeds.', 'gpaisr' ) . ')</small>'; 
  386.  
  387.  
  388. /** 
  389. * field_link_text function. 
  390. * displays the link text settings field 
  391. * @access public 
  392. * @return void 
  393. * @since 0.6 
  394. */ 
  395. function field_link_text() { 
  396. $options = get_option( 'gpaisr' ); 
  397. echo "<input id='gpaisr_link_text' name='gpaisr[link_text]' size='40' type='text' value='" . ( ( ! isset( $options['link_text'] ) ) ? 'Google+' : $options['link_text'] ) . "' />"; 
  398.  
  399.  
  400. /** 
  401. * field_affiliate function. 
  402. * displays the affiliate link to pro-version 
  403. * @access public 
  404. * @return void 
  405. * @since 0.6 
  406. */ 
  407. function field_affiliate() { 
  408. echo '<a href="http://bit.ly/Wn88bZ" target="_blank">' . __( 'Need more options and an automatic test? Check out the Extended Version of this Plugin', 'gpaisr' ) . '</a>'; 
  409.  
  410.  
  411. /** 
  412. * Adds links to the plugins menu (where the plugins are listed) 
  413. * @param array $links 
  414. * @since 0.7 
  415. * @return array 
  416. */ 
  417. public function plugin_action_links( $links ) { 
  418. $links[] = '<a href="' . get_admin_url( null, 'options-general.php?page=' . str_replace( 'settings_page_', '', $this->_pagehook ) ) . '">' . __( 'Settings', 'gpaisr' ) . '</a>'; 
  419. $links[] = '<a href="http://wp-buddy.com/products/" target="_blank">' . __( 'More Plugins by WPBuddy', 'gpaisr' ) . '</a>'; 
  420. return $links; 
  421.  
  422.  
  423. /** 
  424. * Outputs the metabox content for the links 
  425. * @since 0.7 
  426. * @return void 
  427. */ 
  428. public function metabox_links() { 
  429. ?> 
  430. <ul> 
  431. <li> 
  432. <a href="http://wordpress.org/extend/plugins/google-author-information-in-search-results-wordpress-plugin/installation/" target="_blank"><?php echo __( 'Installation manual', 'gpaisr' ); ?></a> 
  433. </li> 
  434. <li> 
  435. <a href="http://wordpress.org/support/plugin/google-author-information-in-search-results-wordpress-plugin" target="_blank"><?php echo __( 'Support forum', 'gpaisr' ); ?></a> 
  436. </li> 
  437. <li> 
  438. <a href="http://wordpress.org/extend/plugins/google-author-information-in-search-results-wordpress-plugin/changelog/" target="_blank"><?php echo __( 'Changelog', 'gpaisr' ); ?></a> 
  439. </li> 
  440. <li><a href="http://bit.ly/ZaaM8S" target="_blank"><?php echo __( 'Get the full version', 'gpaisr' ); ?></a></li> 
  441. <li><a href="http://bit.ly/UlDG4t" target="_blank"><?php echo __( 'More cool stuff by WPBuddy', 'gpaisr' ); ?></a> 
  442. </li> 
  443. </ul> 
  444. <?php