Help needed for simple tweak to WP plugin

Discussion in 'General Scripting Chat' started by mrmidjam, Jun 15, 2010.

  1. mrmidjam

    mrmidjam Regular Member

    Joined:
    Sep 17, 2008
    Messages:
    477
    Likes Received:
    140
    Hi guys,

    I'm trying to customise the wow character display plugin and have successfully changed a few things around but, I'm stuck on trying to get checkboxes checked by default.

    I think this plugin was designed to hold only a few characters as it displays every character and all thier stats on one page which makes this page very load hungry. I have removed the stats from the page which helps but, I still have to scroll down to the bottom of the page and check all the check boxes I need checked. I have tried to edit the code to turn these checkboxes on by default and then hide them but, nothing has worked.

    [​IMG]

    Here is the code:

    Code:
    		// Display and configure existing characters
    		if( is_array( $this -> wowcd_AdminOptions[ 'wowcdOptionCharacters' ] ) && count( $this -> wowcd_AdminOptions[ 'wowcdOptionCharacters' ] ) )
    		{
    			print "<div id=\"poststuff\">\n";
    			print "<div class=\"postbox\">\n";
    			print "<form name=\"wowcdAdminPageConfigureChar\" method=\"POST\" action=\"options-general.php?page=wow-character-display.php\">\n";
    			print "<input type=\"hidden\" name=\"wowcd_admin_action\" value=\"set_character_options\"/>\n";
    			print "<h3>" . __( "Your characters", "wowcd" ) . "</h3>\n";
    			print "<div class=\"inside\">\n";
    			print "<h4>" . __( "Configure what informations were displayed for your characters", "wowcd" ) . "</h4>";
    			// Edit CSS to shorten preview
    			if( $this -> wowcd_AdminOptions[ 'wowcdOptionPreviewType' ] == 'short' )
    				echo "<style type=\"text/css\">.wow_character { overflow:hidden; height:85px }</style>";
    			print "<table class=\"form-table\">\n";
    			foreach( $this -> wowcd_AdminOptions[ 'wowcdOptionCharacters' ] AS $character => $options )
    			{
    				$characterfieldname = preg_replace( '/[^a-z0-9]/i', '', $character );
    
    				// Set default values if entity not exists
    				if( !isset( $options -> display ) )
    					$options -> display = array( 'display_basic_stats' => 1, 'display_resistances' => 0, 'display_melee' => 0, 'display_range' => 0, 'display_spell' => 0, 'display_caster_stats' => 0, 'display_defense' => 0, 'display_pvp' => 0, 'display_titles' => 0, 'display_gear' => 1, 'display_professions' => 1, 'display_achievments' => 1, 'display_statistics' => 0, 'display_reputation' => 0, 'display_last_update_string' => 0, 'display_glyphs' => 0 );
    				// Set options for character
    				print "<tr valign=\"top\" style=\"border-bottom:1px solid #999\"><td width=\"50%\"><a name=\"$characterfieldname\"></a><strong>$character</strong><br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_basic_stats' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_basic_stats\"/> " . __( "Display basic stats", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_resistances' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_resistances\"/> " . __( "Display resistances", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_melee' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_melee\"/> " . __( "Display melee damage", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_range' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_range\"/> " . __( "Display range damage", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_spell' ] ? "checked=\"checked\"" : "") . " name=\"$character"."_display_spell\"/> " . __( "Display spell damage", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_caster_stats' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_caster_stats\"/> " . __( "Display caster stats", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_defense' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_defense\"/> " . __( "Display defense values", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_pvp' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_pvp\"/> " . __( "Display PvP honor", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_titles' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_titles\"/> " . __( "Display titles", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_gear' ] ? "checked=\"checked\"" : "") . " name=\"$character"."_display_gear\"/> " . __( "Display gear", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_professions' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_professions\"/> " . __( "Display professions", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_achievments' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_achievments\"/> " . __( "Display recent achievments", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_statistics' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_statistics\"/> " . __( "Display statistics", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_reputation' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_reputation\"/> " . __( "Display reputation", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_last_update_string' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_last_update_string\"/> " . __( "Display date and time of last update", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_glyphs' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_glyphs\"/> " . __( "Display glyphs", "wowcd" ) . "<br/>";
    				print "<input type=\"checkbox\" value=\"1\" " . ($options ->display[ 'display_3darmory' ] ? "checked=\"checked\"" : "") . " name=\"$characterfieldname"."_display_3darmory\"/> " . __( "Display 3D Armory flash model", "wowcd" ) . "<br/>";
    				print "<input type=\"text\" size=\"5\" value=\"" . $options ->display[ 'display_3darmory_width' ] . "\" name=\"$characterfieldname"."_display_3darmory_width\"/> " . __( "3D Armory flash width", "wowcd" ) . " ";
    				print "<input type=\"text\" size=\"5\" value=\"" . $options ->display[ 'display_3darmory_height' ] . "\" name=\"$characterfieldname"."_display_3darmory_height\"/> " . __( "3D Armory flash height", "wowcd" ) . "<br/>";
    				// Output shortcode
    				print "<br/>" . __( "To display this character in a page or post, use the following shortcode:", "wowcd" ) . "<br/><strong>[wowcd character=\"$character\"]</strong>";
    				// Refresh, remove buttons
    				print "<div class=\"submit\">";
    				print "<input type=\"button\" name=\"refresh_wowcdAdminDelHtmlChar\" value=\"" . __( "Refresh HTML", "wowcd" ) . "\" onclick=\"window.location.href='options-general.php?page=wow-character-display.php&wowcd_admin_action=refresh_char_html&character=$character&r=" . rand() . "#$characterfieldname';\"/>\n";
    				print "<input type=\"button\" name=\"refresh_wowcdAdminDelCacheChar\" value=\"" . __( "Refresh HTML+XML", "wowcd" ) . "\" onclick=\"if(confirm('" . __( "Really refresh?", "wowcd" ) . "'))window.location.href='options-general.php?page=wow-character-display.php&wowcd_admin_action=refresh_char&character=$character&r=" . rand() . "#$characterfieldname';\"/>\n";
    				print "<input type=\"button\" name=\"remove_wowcdAdminDelChar\" value=\"" . __( "Remove", "wowcd" ) . "\" onclick=\"if(confirm('" . __( "Really delete?", "wowcd" ) . "'))window.location.href='options-general.php?page=wow-character-display.php&wowcd_admin_action=remove_char&character=$character';\"/>\n";
    				print "</div>\n";
    				print "</td>";
    				// Display preview
    				if( $this -> armory_reader -> get_character_information( $options -> rt, $options -> wl, $options -> server, $options -> character, $options -> display[ 'display_basic_stats' ], $options -> display[ 'display_resistances' ], $options -> display[ 'display_melee' ], $options -> display[ 'display_range' ], $options -> display[ 'display_spell' ], $options -> display[ 'display_caster_stats' ], $options -> display[ 'display_defense' ], $options -> display[ 'display_pvp' ], $options -> display[ 'display_titles' ], $options -> display[ 'display_gear' ], $options -> display[ 'display_professions' ], $options -> display[ 'display_achievments' ], $options -> display[ 'display_statistics' ], $options -> display[ 'display_reputation' ], $options -> display[ 'display_last_update_string' ], $options -> display[ 'display_glyphs' ], $options -> display[ 'display_3darmory' ], $options -> display[ 'display_3darmory_width' ], $options -> display[ 'display_3darmory_height' ] ) )
    					$preview = $this -> armory_reader -> get_content();
    				else
    					$preview = __( "Error:", "wowcd" ) . " " . $this -> armory_reader -> error;
    				if( $this -> wowcd_AdminOptions[ 'wowcdOptionPreviewType' ] == 'short' )
    					$preview .= "<a href=\"javascript:void(0);\" onclick=\"jQuery('.wow_character-$character').css({overflow:'visible',height:'auto'}); this.style.display='none';\">" . __( "Display full preview", "wowcd" ) . "</a>";
    				print "<td></td></tr>\n";
    			}
    			print "</table>\n";
    			// Submit
    			print "<div class=\"submit\"><input type=\"submit\" name=\"update_wowcdAdminAddChar\" value=\"" . __( "Save configuration", "wowcd" ) . "\"/></div>\n";
    			print "</form>\n";
    			print "</div>\n";
    			print "</div>\n";
    			print "</div>\n";
    		}
    Any help would be fantastic! :)
     
    Last edited: Jun 15, 2010
  2. yeahright

    yeahright Registered Member

    Joined:
    Jan 17, 2009
    Messages:
    93
    Likes Received:
    32
    To hide the checkboxes simply change:

    PHP:
    print "<input type=\"checkbox\"....
    to...

    PHP:
    print "<input type=\"hidden\"....
    And to have them checked by default make sure they all have:

    PHP:
    "checked=\"checked\"
     
    • Thanks Thanks x 1
  3. mrmidjam

    mrmidjam Regular Member

    Joined:
    Sep 17, 2008
    Messages:
    477
    Likes Received:
    140
    Wicked it worked, thanks for the help!!!