WordPress.org

Ready to get started?Download WordPress

Forums

Google Adsense Plug and Play
Doesn't work in multisite installs for normal admins (4 posts)

  1. mkilian
    Member
    Posted 1 year ago #

    Hi,

    normal admins (not network-admins) can't change the settings of this plugin in a multisite installation.

    Here's a diff which adds proper calls to register_setting() and replaces the call to wp_nonce_field() by settings_fields(), which fixes the problem (i'd upload the diff into a trac ticket, but unfortunately this plugin isn't configured as a component in the trac at wordpress.org):

    Index: google-adsense-plug-and-play.php
    ===================================================================
    --- google-adsense-plug-and-play.php	(revision 650734)
    +++ google-adsense-plug-and-play.php	(working copy)
    @@ -11,13 +11,26 @@
     if (!class_exists("GoogleAdsensePlugAndPlay")) {
     	class GoogleAdsensePlugAndPlay {
     		function GoogleAdsensePlugAndPlay() { //constructor
    -
    +			add_action('admin_init', array(&$this, 'admin_init'));
     		}
     		function addHeaderCode() {
     			?>
     			<?php
    
     		}
    +		function admin_init() {
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_backgroundcolor');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_bordercolor');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_bottomadtype');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_displaypages');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_displayposts');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_publisherid');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_support');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_textcolor');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_titlecolor');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_topadtype');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_urlcolor');
    +		}
     		function addContent($content = '') {
      	 	  global $wp_query;
     	 	  global $post;
    @@ -264,7 +277,7 @@
     <h2>Google Adsense Plug and Play - Settings</h2>
    
     <form method="post" action="options.php">
    -<?php wp_nonce_field('update-options'); ?>
    +<?php settings_fields('google_adsense_plug_and_play'); ?>
    
     <table width="850">
     <tr valign="top">

    http://wordpress.org/extend/plugins/google-adsense-plug-and-play/

  2. mkilian
    Member
    Posted 1 year ago #

    Better (removes obsolete hidden input fields, those are now created by settings_fields()):

    --- google-adsense-plug-and-play.php.orig	Thu Jan 10 13:00:15 2013
    +++ google-adsense-plug-and-play.php	Thu Jan 10 16:31:02 2013
    @@ -11,13 +11,26 @@
     if (!class_exists("GoogleAdsensePlugAndPlay")) {
     	class GoogleAdsensePlugAndPlay {
     		function GoogleAdsensePlugAndPlay() { //constructor
    -
    +			add_action('admin_init', array(&$this, 'admin_init'));
     		}
     		function addHeaderCode() {
     			?>
     			<?php
    
     		}
    +		function admin_init() {
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_backgroundcolor');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_bordercolor');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_bottomadtype');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_displaypages');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_displayposts');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_publisherid');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_support');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_textcolor');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_titlecolor');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_topadtype');
    +			register_setting('google_adsense_plug_and_play', 'google_adsense_plug_and_play_urlcolor');
    +		}
     		function addContent($content = '') {
      	 	  global $wp_query;
     	 	  global $post;
    @@ -261,7 +274,7 @@
     <h2>Google Adsense Plug and Play - Settings</h2>
    
     <form method="post" action="options.php">
    -<?php wp_nonce_field('update-options'); ?>
    +<?php settings_fields('google_adsense_plug_and_play'); ?>
    
     <table width="850">
     <tr valign="top">
    @@ -369,9 +382,6 @@
     </tr>
     </table>
    
    -
    -<input type="hidden" name="action" value="update" />
    -<input type="hidden" name="page_options" value="google_adsense_plug_and_play_publisherid, google_adsense_plug_and_play_bordercolor, google_adsense_plug_and_play_titlecolor, google_adsense_plug_and_play_backgroundcolor, google_adsense_plug_and_play_textcolor, google_adsense_plug_and_play_urlcolor, google_adsense_plug_and_play_topadtype, google_adsense_plug_and_play_bottomadtype, google_adsense_plug_and_play_displayposts, google_adsense_plug_and_play_displaypages, google_adsense_plug_and_play_support" />
    
     <p>
     <input type="submit" value="<?php _e('Save Changes') ?>" />
    @@ -382,4 +392,4 @@
     <BR><BR>
     <?php
     }
    -?>
    \ No newline at end of file
    +?>
  3. mkilian
    Member
    Posted 1 year ago #

    How about applying the above diff and fixing the plugin instead of releasing a new version which only contains your stupid advertising links?

  4. earthsprite
    Member
    Posted 1 year ago #

    Report the plugin to plugins@wordpress.org if it violates the terms of WP org.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.