Plugin refuzat de WordPress – Ghinion mare

De câteva zile m-am apucat de făcut un plugin pentru toți utilizatorii blogurilor de pe platforma wordpress. Toate bune și frumoase l-am verificat din toate punctele de vedere și l-am făcut să fie și compatibil cu versiunea 3.8.1 cea de azinoapte. M-am gândit să nu-l păstrez în calculator și să-l urc pe wordpress că toți membri să se poată bucură de el.

Verificarea a fost una foarte rapidă întrucât pe la oră 03:00 am primit și răspunsul de la ei 🙁 .

There are issues with your code.

== Calling wp-config.php directly ==

Including wp-config.php, wp-blog-header.php, wp-load.php, or pretty much any other WordPress core file that you have to call directly via an include is not a good idea and we cannot approve a plugin that does so unless it has a very good reason to load the file(s). It is prone to failure since not all WordPress installs have the exact same file structure.

Usually plugins will include wp-config.php or wp-load.php in order to gain access to core WordPress functions, but there are much better ways to do this.

It’s best if you tie your processing functions (the ones that need but don’t have access to core functions) into an action hook, such as „init” or „admin_init”.

Daca aveti ceva de completat la acest plugin anuntati-ma. locco_smiley_41

<?php
/*
Plugin Name: Locco Emoticons
Plugin URI: http://locco.ro
Description: Plugin creat pentru toti membrii blogosferei. This plugin was made for all the bloggers.
Version: 1.0
Author: LoccoChicco
Author URI: http://locco.ro

Copyright 2014

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

register_activation_hook( __FILE__, array('Locco_RoEmoticons', 'activate'));
register_deactivation_hook( __FILE__, array('Locco_RoEmoticons', 'deactivate'));
add_filter('the_content',array('Locco_RoEmoticons','replace'));
add_filter('comment_text',array('Locco_RoEmoticons','replace'));
add_action('comment_form', array('Locco_RoEmoticons', 'scut'));
add_action('wp_head', array('Locco_RoEmoticons', 'script'));
add_action('admin_menu', array('Locco_RoEmoticons','menu'));
add_filter( 'plugin_action_links', array('Locco_RoEmoticons', 'link'), 10, 2 );
add_action('media_buttons', array('Locco_RoEmoticons', 'add_button'), 30);

require_once("Locco_Ro-emoticons-list.php");

if(!class_exists('Locco_RoEmoticons')){
	class Locco_RoEmoticons {
		function activate(){
			$data = array(
				'backlink'=> 1
			);
	    	if (!get_option('Locco_Ro_emoticons')){
	      		add_option('Locco_Ro_emoticons', $data);
	    	} else {
	      		update_option('Locco_Ro_emoticons', $data);
	    	}
		}

		function deactivate(){
			//delete_option('Locco_Ro_emoticons');
		}

		function link( $links, $file ){
			static $this_plugin;
			if ( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__);

			if ( $file == $this_plugin ){
				$settings_link = '<a href="options-general.php?page=Locco_RoEmoticons">' . __('Settings') . '</a>';
				array_unshift( $links, $settings_link ); // before other links
			}
			return $links;
		}

		function menu(){
			add_options_page('Locco Emoticons', 'Locco Emoticons', 8, 'Locco_RoEmoticons', array('Locco_RoEmoticons','control'));
		}

		function control() {
			//die(print_r($_POST,true));
			global $KEEUrl,$KEReplace2;
			$options = $newoptions = get_option('Locco_Ro_emoticons');
			//die(print_r($options,true));
			if($_POST["Locco_Ro_emoticons_action"]) {
				//print_r($_POST);
				$kes = null;
				if(isset($_POST['Locco_Ro_emoticons_stat']) && count($_POST['Locco_Ro_emoticons_stat'])>0){
					foreach($_POST['Locco_Ro_emoticons_stat'] as $k=>$v){
						$kes[$k]='';
					}
				}
				$newoptions['stat'] = $kes;
				$newoptions['backlink'] 	= strip_tags(stripslashes($_POST["Locco_Ro_emoticons_backlink"]));
				if(trim($newoptions['backlink'])=="") $newoptions['backlink'] = 1;
			}
			if ($options != $newoptions) {
				$options = $newoptions;
				//print_r($options);
				update_option('Locco_Ro_emoticons', $options);
			}

			$backlink= htmlspecialchars($options['backlink'], ENT_QUOTES);
			$check = get_option('siteurl') . '/wp-content/plugins/Locco_Ro-emoticons/checkbox';
			$check0= $check."0.gif";
			$check1= $check."1.gif";
?>
			<style type="text/css">
			.codelist{
				border-collapse: collapse;
			}
			.codelist td{
				border: 1px solid #eee;
				vertical-align: middle;
				padding: 2px;
			}

			.code-row{
				background: none;
				cursor: pointer;
			}

			.code-row-checked{
				background: #dfdfdf;
			}

			.code-row-hover{
				background: white;
			}

			.code-check0{
				background:url("<?php echo $check0;?>") no-repeat scroll center center transparent;
			}

			.code-check1{
				background:url("<?php echo $check1;?>") no-repeat scroll center center transparent;
			}
			</style>
			<img src="<?php echo $check0;?>" style="display:none">
			<img src="<?php echo $check1;?>" style="display:none">
			<h2>Emoticoane pentru wordpress</h2>
			<em>Plugin oferit de  <a href="http://locco.ro" target="_blank">Andrei Sebastian</a> </em><br /><br />
			Daca folosesti acest plugin nu uita sa-i dai o bere autorului <a href="http://www.Locco.ro" target="_blank">Andrei Sebastian</a><br />
			Sunt prezent si pe twitter - <a href="http://twitter.com/LoccoChicco" target="_blank">twitter.com/LoccoChicco</a> <br /><br />
			<form method="post" action="options-general.php?page=Locco_RoEmoticons">
			<table>
			<tr>
			<td><?php _e('Pentru backlink ! Poti sa-l dezactivezi dar daca il activezi, Multam fain!'); ?></td>
			<td>
				<select name="Locco_Ro_emoticons_backlink">
					<option value="1"<?php echo($backlink=="1"?" selected":"")?>>Activeaza</option>
					<option value="0"<?php echo($backlink=="1"?"":" selected")?>>Dezactiveaza</option>
				</select>
			</td>
			</tr>
			<tr>
				<td colspan="2">
					<table class="codelist" align="center" cellpadding="0" cellspacing="0" border="0">
					<tr style="background:#ccc;">
						<td align="center"><strong>Dezactiveaza</strong></td>
						<td align="center"><strong>Imagine</strong></td>
						<td align="center"><strong>Codul folosit</strong></td>
					</tr>
					<?php 
					foreach($KEReplace2 as $k=>$v):
						$xstat = isset($options['stat']) && isset($options['stat'][$k]);
					?>
					<tr class="code-row<?php echo ($xstat?" code-row-checked":"");?>">
						<td align="center" class="code-check<?php echo ($xstat?1:0);?>"><input <?php echo ($xstat ? "checked="checked"":"");?> name="Locco_Ro_emoticons_stat[<?php echo $k;?>]" type="checkbox" style="display:none"></td>
						<td align="center"><?php echo $v;?></td>
						<td><?php echo $k;?></td>
					</tr>
					<?php endforeach;?>
					</table>
				</td>
			</tr>
			</table>
			<input type="hidden" id="Locco_Ro_emoticons_action" name="Locco_Ro_emoticons_action" value="1" /><br />
			<input type="submit" id="Locco_Ro_emoticons_submit" name="Locco_Ro_emoticons_submit" value="Save Settings" />
			</form>
			<script language="javascript">
			jQuery(".code-row").each(function(i){
				jQuery(this).mouseover(function(){
					jQuery(this).addClass("code-row-hover");
				}).mouseout(function(){
					jQuery(this).removeClass("code-row-hover");
				}).click(function(){
					if((jQuery(this).find(":checkbox")[0]).checked){
						(jQuery(this).find("td")[0]).className = "code-check0";
						jQuery(this).removeClass("code-row-checked");
					}
					else{
						jQuery(this).addClass("code-row-checked");
						(jQuery(this).find("td")[0]).className = "code-check1";
					}
					(jQuery(this).find(":checkbox")[0]).checked = !(jQuery(this).find(":checkbox")[0]).checked;
				});
			});
			</script>
<?php
		}

		function replace($string){
			//die($string);
			$output = '';
			$textarr = preg_split("/(</?pre[^>]*>)|(</?p[^>]*>)|(</?a[^>]*>)|(</?object[^>]*>)|(</?img[^>]*>)|(</?embed[^>]*>)|(</?strong[^>]*>)|(</?b[^>]*>)|(</?i[^>]*>)|(</?em[^>]*>)/U", $string, -1, PREG_SPLIT_DELIM_CAPTURE); 
			$stop = count($textarr);
			//die(print_r($opt['stat'],true));
			$s=false;
			for ($i = 0; $i < $stop; $i++){
				$content = $textarr[$i];
				if(preg_match("/^<img/",trim($content))){
					$output .= $content;
					continue;
				}
				if(preg_match("/^<pre/",trim($content)))$s = true;
				if(trim($content)=="^</pre>")$s = false;
				//if (!$s && (strlen($content) > 0) && ('<' != $content{0}))
				if (!$s)
				{ 
					$content = Locco_RoEmoticons::replace_code( $content ) ;
				}
				$output .= $content;
			}

			return $output;

		}

		function replace_code($content){
			global $KEReplace;
			//print_r($content);die;
			return strtr($content,$KEReplace);
		}

		function add_button(){
			$pl_dir 	= get_option('siteurl') . '/wp-content/plugins/Locco_Ro-emoticons/';
	        $wizard_url = $pl_dir . 'Locco_Ro-emoticons-wizard.php';
	        $button_src = $pl_dir.'Locco_Ro.jpg';
	        $button_tip = 'Insert a Locco_Ro Emoticon';
	        $pl_dir		= ABSPATH . 'wp-content/plugins/Locco_Ro-emoticons/';
	        echo '<a title="Add a Locco_Ro Emoticon" href="'.$wizard_url.'?pl_dir='.$pl_dir.'&KeepThis=true&TB_iframe=true" class="thickbox" ><img src="' . $button_src . '" alt="' . $button_tip . '" /></a>';
		}

		function scut(){
			global $KEReplace;
			$opt = get_option('Locco_Ro_emoticons');
			echo "<div style="cursor:pointer;margin:2px" onclick="Locco_Roemoticonsclink()"><span id='Locco_Roemoticonslink'><strong>Afiseaza Emoticoanele</strong></span>";
			if(isset($opt['backlink']) && $opt['backlink']) echo "&nbsp;<a target="_blank" href="http://locco.ro">Locco.Ro</a>";
			else {
				if(!isset($opt['backlink']))  echo "&nbsp;<a target="_blank" href="http://locco.ro">Locco.Ro</a>";
			}
			echo "</div>";
			echo "<div id='Locco_Roemoticonscontent' style="display:none">";
			foreach($KEReplace as $k=>$v){
				if(isset($opt['stat']) && isset($opt['stat'][$k])){}
				else echo "<a title="".$k."" href="javascript:Locco_Roemoticonsclick('".$k."')" style="cursor:pointer;margin:1px;border:none">".$v."</a>";
			}
			echo "</div>"; 
		}

		function script(){
?>
<script language="javascript">
	var gOI = function(id){
		return document.getElementById(id);
	};

	var Locco_Roemoticonsclick = function(tag){
		var d = gOI("comment");
		var b = d.selectionStart, a = d.selectionEnd;
		d.value = d.value.substring(0, b) + " " + tag + " " + d.value.substring(a, d.value.length);
	};

	var Locco_Roemoticonsclink = function(){
		gOI("Locco_Roemoticonslink").innerHTML = gOI("Locco_Roemoticonscontent").style.display == "" ? "<strong>Afiseaza Emoticoanele</strong>":"<strong>Ascunde Emoticoanele</strong>";
		gOI("Locco_Roemoticonscontent").style.display = gOI("Locco_Roemoticonscontent").style.display == "" ? "none":"";
	};
</script>	
<?php
		}
	}
}
?>

<?php
$KEEUrl = get_option('siteurl') . '/wp-content/plugins/Locco_Ro-emoticons/Locco/';
$opt 	= get_option('Locco_Ro_emoticons');

$KEReplace	= array(
	':D' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_42.gif" style="border:none;background:none;" alt=":D" />',
	':O' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_33.gif" style="border:none;background:none;" alt=":o" />',
	':(' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_54.gif" style="border:none;background:none;" alt=":(" />',
	':)' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_53.gif" style="border:none;background:none;" alt=":)" />',
	'=))' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_44.gif" style="border:none;background:none;" alt="=))" />',
	':P' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_1.gif" style="border:none;background:none;" alt=":p" />',
	';)' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_50.gif" style="border:none;background:none;" alt=";)" />',
	//////DE BAZA/////
	  'locco_smiley_1' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_2.gif" style="border:none;background:none;" alt=":D" />',
	'locco_smiley_2' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_3.gif" style="border:none;background:none;" alt=":D" />',
	'locco_smiley_3' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_4.gif" style="border:none;background:none;" alt=":o" />',
	'locco_smiley_4' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_5.gif" style="border:none;background:none;" alt=":o" />',
	'locco_smiley_5' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_6.gif" style="border:none;background:none;" alt=":(" />',
	'locco_smiley_6' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_7.gif" style="border:none;background:none;" alt=":)" />',
	'locco_smiley_7' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_8.gif" style="border:none;background:none;" alt=":p" />',
	'locco_smiley_8' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_9.gif" style="border:none;background:none;" alt="=))" />',
	'locco_smiley_9' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_10.gif" style="border:none;background:none;" alt=":p" />',
	'locco_smiley_10' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_11.gif" style="border:none;background:none;" alt=";)" />',
	'locco_smiley_11' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_12.gif" style="border:none;background:none;" alt=":D" />',
	'locco_smiley_12' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_13.gif" style="border:none;background:none;" alt=":D" />',
	'locco_smiley_13' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_14.gif" style="border:none;background:none;" alt=":o" />',
	'locco_smiley_14' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_15.gif" style="border:none;background:none;" alt=":o" />',
	'locco_smiley_15' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_16.gif" style="border:none;background:none;" alt=":(" />',
	'locco_smiley_16' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_17.gif" style="border:none;background:none;" alt=":)" />',
	'locco_smiley_17' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_18.gif" style="border:none;background:none;" alt=":p" />',
	'locco_smiley_18' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_19.gif" style="border:none;background:none;" alt="=))" />',
	'locco_smiley_19' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_20.gif" style="border:none;background:none;" alt=":p" />',
	'locco_smiley_20' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_21.gif" style="border:none;background:none;" alt=";)" />',
	'locco_smiley_21' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_22.gif" style="border:none;background:none;" alt=":D" />',
	'locco_smiley_22' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_23.gif" style="border:none;background:none;" alt=":D" />',
	'locco_smiley_23' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_24.gif" style="border:none;background:none;" alt=":o" />',
	'locco_smiley_24' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_25.gif" style="border:none;background:none;" alt=":o" />',
	'locco_smiley_25' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_26.gif" style="border:none;background:none;" alt=":(" />',
	'locco_smiley_26' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_27.gif" style="border:none;background:none;" alt=":)" />',
	'locco_smiley_27' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_28.gif" style="border:none;background:none;" alt=":p" />',
	'locco_smiley_28' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_29.gif" style="border:none;background:none;" alt="=))" />',
	'locco_smiley_29' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_30.gif" style="border:none;background:none;" alt=":p" />',
	'locco_smiley_30' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_31.gif" style="border:none;background:none;" alt=";)" />',
	'locco_smiley_41' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_32.gif" style="border:none;background:none;" alt=";)" />',
	'locco_smiley_42' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_34.gif" style="border:none;background:none;" alt=";)" />',
	'locco_smiley_43' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_35.gif" style="border:none;background:none;" alt=";)" />',
	'locco_smiley_44' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_36.gif" style="border:none;background:none;" alt=";)" />',
	'locco_smiley_45' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_37.gif" style="border:none;background:none;" alt=";)" />',
	'locco_smiley_46' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_38.gif" style="border:none;background:none;" alt=";)" />',
	'locco_smiley_47' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_39.gif" style="border:none;background:none;" alt=";)" />',
	'locco_smiley_40' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_40.gif" style="border:none;background:none;" alt=";)" />',
	'locco_smiley_31' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_41.gif" style="border:none;background:none;" alt=":D" />',
	'locco_smiley_32' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_43.gif" style="border:none;background:none;" alt=":D" />',
	'locco_smiley_33' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_45.gif" style="border:none;background:none;" alt=":o" />',
	'locco_smiley_34' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_46.gif" style="border:none;background:none;" alt=":o" />',
	'locco_smiley_35' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_47.gif" style="border:none;background:none;" alt=":(" />',
	'locco_smiley_36' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_48.gif" style="border:none;background:none;" alt=":)" />',
	'locco_smiley_37' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_49.gif" style="border:none;background:none;" alt=":p" />',
	'locco_smiley_38' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_51.gif" style="border:none;background:none;" alt="=))" />',
	'locco_smiley_39' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_52.gif" style="border:none;background:none;" alt=":p" />',
		':d' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_42.gif" style="border:none;background:none;" alt=":D" />',
			':o' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_33.gif" style="border:none;background:none;" alt=":o" />',
				':p' => '<img src="'. $KEEUrl.'Locco_Ro_smiley_1.gif" style="border:none;background:none;" alt=":p" />',

);
$KEReplace2 = $KEReplace;
if(isset($opt['stat'])){
	foreach($opt['stat'] as $k=>$v){
		$KEReplace[$k]="";
	}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  dir="ltr" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
body{
    text-align:center;
    font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera";
}
</style>
</head>
<body>
<?php
$httphost = @$_SERVER['HTTP_HOST'];
$httpreferer = @$_SERVER['HTTP_REFERER'];
$nonce = isset($_POST['nonce'])?$_POST['nonce']:"";
require_once '../../../wp-config.php';
include("Locco_Ro-emoticons-list.php");
//print_r($KEEUrl);die;
//$opt = get_option('Locco_Ro_emoticons');
foreach($KEReplace as $k=>$v){
	//if(isset($opt['stat']) && isset($opt['stat'][$k])){}
	echo "<a title="".$k."" href="javascript:window.parent.send_to_editor(' ".$k." ')" style="cursor:pointer;margin:1px;border:none">".$v."</a>";
}
?>
</body>
</html>

Problema a fost în ultimul fișier, în linia asta

require_once '../../../wp-config.php';

Dacă doriți arhiva completă anunțați-mă fără dar și poate v-o trimit.
Oricum nu mă las până nu-mi urc un plugin in wordpress. Aveam planuri mari și pentru acesta, pregăteam update-uri săptamanale, dar na…asta e locco_smiley_6  wordpress.

Stai la curent cu stirile zilei de pe ucoz.ro. Iar daca vrei permis de conducere, incearca www.ChestionareAuto.ro.

4 thoughts on “Plugin refuzat de WordPress – Ghinion mare

  1. Păi tati, bănuiesc că nu se face prin apelarea directă a fişierului wp-config.php. Şi de ce să ai nevoie de includerea lui?

    Dacă nu reuşeşti şi îmi fac timp, zilele astea, te ajut cu el să-l pui pe picioare 😉

Lasă un răspuns