msrougi

Plugin-faltando-mask

Apr 30th, 2017
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.68 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: link_Ex
  4. Plugin URI: https://www.freelancer.com/u/al6ayib.html
  5. Description:Use [LE_link_Ex_Table] for showing the table, and [LE_link_Ex] for adding websites.
  6. lklkl
  7. Version: 1.0
  8. Author: Aaltayib Abdalla
  9. Author URI: https://www.freelancer.com/u/al6ayib.html
  10. */
  11.  
  12.  
  13.  
  14. function link_EX_function() {
  15. install();
  16. if (isset($_POST['submit'])) {
  17. registration_validation(
  18. $_POST['sitename'],
  19. $_POST['website'],
  20. $_POST['niche'],
  21. $_POST['keywords']
  22. );
  23.  
  24. // sanitize user form input
  25. global $sitename, $website, $niche, $keywords;
  26. //$id = sanitize_user($_POST['id']);
  27. //$user_id = esc_attr($_POST['user_id']);
  28. $sitename = sanitize_text_field($_POST['sitename']);
  29. $website = esc_url($_POST['website']);
  30. $niche = sanitize_text_field($_POST['niche']);
  31. $keywords = esc_textarea($_POST['keywords']);
  32.  
  33. // call @function complete_registration to create the user
  34. // only when no WP_error is found
  35. complete_registration(
  36. $sitename,
  37. $user_id,
  38. $website,
  39. $niche,
  40. $keywords
  41. );
  42. }
  43.  
  44. registration_form(
  45. $sitename,
  46. $website,
  47. $niche,
  48. $keywords
  49. );
  50. }
  51. function registration_form($sitename, $website, $niche, $keywords) {
  52. $niches = [
  53. 'Adulto',
  54. 'Afiliado/mini-site',
  55. 'Automotivo',
  56. 'Blog',
  57. 'Música',
  58. 'Notícias',
  59. 'Negócios',
  60. 'Tecnologia',
  61. 'Relacionamento',
  62. 'Receitas/Comida',
  63. 'Games',
  64. 'Cassino',
  65. 'Saúde/Emagrecimento',
  66. 'Pets/Animais',
  67. 'SEO',
  68. 'E-commerce',
  69. 'Esportes',
  70. 'Viagens',
  71. 'Outros'
  72. ];
  73. echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post"><div class="cadastro">
  74. <label for="sitename">Nome do Site </label>
  75. <input type="text" name="sitename" value="' . (isset($_POST['sitename']) ? $sitename : null) . '">
  76. </div><div class="cadastro"><label for="website">URL (com http:// ou https://)</label>
  77. <input type="text" name="website" value="' . (isset($_POST['website']) ? $website : null) . '">
  78. </div>
  79. <div class="cadastro">
  80. <label for="niche">Nicho</label>
  81. <select name="niche">';
  82. echo '<option value="">Selecione</option>';
  83. foreach($niches as $n){
  84. echo '<option ';///////
  85. if(isset($_POST['niche'])){
  86. if($niche == $n) echo ' selected ';
  87. }
  88. //////
  89. echo ' value="'.$n.'">'.$n.'</option>';
  90. }
  91. echo '
  92. </select>
  93. </div>
  94. <div class="cadastro"><label for="keywords">Keywords ou Nichos</label>
  95. <input type="text" name="keywords" value="' . (isset($_POST['keywords']) ? $keywords : null) . '">
  96. </div>
  97. <div class="cadastro"><input type="submit" class="cadastro-enviar" name="submit" value="Adicionar website"/>
  98. </form></div>
  99. ';
  100. }
  101.  
  102. function registration_validation($sitename, $website, $niche, $keywords) {
  103. global $reg_errors, $user_id;
  104. $reg_errors = new WP_Error;
  105.  
  106. if(is_user_logged_in()) {
  107. $current_user = wp_get_current_user();
  108. $user_id = $current_user->ID;
  109. //print_r($current_user);
  110. //printf( 'Personal Message For %s!', esc_html( $current_user->user_pass ) );
  111. } else{
  112. $reg_errors->add('field', 'Você não fez login. <a href="' . get_site_url() . '/wp-login.php"><span style="text-decoration:underline; color:#2991d6;">Ir para a página de login</span></a>.');
  113. }
  114.  
  115.  
  116. if ( empty($website) || empty($sitename) || empty($keywords)) {
  117. $reg_errors->add('field', 'Preencha todos os campos requeridos.');
  118. }
  119.  
  120. if($niche == null){
  121. $reg_errors->add('field', 'Selecione o nicho.');
  122. }
  123.  
  124.  
  125. if ( email_exists( $email ) ) {
  126. //$reg_errors->add('email', 'E-mail já em uso.');
  127. }
  128.  
  129. if ( !empty( $website ) ) {
  130. if ( !filter_var($website, FILTER_VALIDATE_URL) ) {
  131. $reg_errors->add('website', 'URL inválida (não se esqueça de incluir o http ou https');
  132. } else {
  133. global $wpdb;
  134. $table_name = $wpdb->prefix.'link_ex';
  135. if($wpdb->get_results( "SELECT * FROM $table_name WHERE website LIKE '$website'" )){
  136. $reg_errors->add('website', 'URL já existe!');
  137. }
  138. }
  139. }
  140.  
  141. if ( is_wp_error( $reg_errors ) ) {
  142.  
  143. foreach ( $reg_errors->get_error_messages() as $error ) {
  144. echo '<div>';
  145. echo '<h4><strong style="color:red">ERRO: </strong>';
  146. echo $error . '</h4><br/>';
  147.  
  148. echo '</div>';
  149. }
  150. }
  151. }
  152.  
  153. function complete_registration() {
  154. global $reg_errors, $user_id, $sitename, $email, $website, $niche, $keywords, $wpdb;
  155. if ( count($reg_errors->get_error_messages()) < 1 ) {
  156. $data = array(
  157. 'name' => $sitename,
  158. 'user_id' => $user_id,
  159. 'website' => $website,
  160. 'niche' => $niche,
  161. 'keywords' => $keywords
  162. );
  163. global $wpdb;
  164. $table_name = $wpdb->prefix.'link_ex';
  165. $wpdb->insert($table_name, $data);
  166.  
  167. $user = wp_insert_user( $userdata );
  168. $_POST = null;
  169. echo 'Adicionado com sucesso!';
  170. }
  171. }
  172.  
  173.  
  174. ///////////////////////////////////////////////////
  175.  
  176. function html(){
  177. install();
  178. delete();
  179. if(isset($_POST['sender_name'])){
  180. email();
  181. }
  182.  
  183. global $wpdb;
  184. $table_name = $wpdb->prefix.'link_ex';
  185. $data = $wpdb->get_results( "SELECT * FROM $table_name" );
  186.  
  187. $linDir = plugin_dir_path( __FILE__ );
  188. wp_enqueue_style( 'dataTables.material', get_site_url().'/wp-content/plugins/link_Ex/css/dataTables.material.css',false,'1.1','all');
  189. wp_enqueue_style( 'shCore', get_site_url().'/wp-content/plugins/link_Ex/css/shCore.css',false,'1.1','all');
  190. wp_enqueue_style( 'demo', get_site_url().'/wp-content/plugins/link_Ex/css/demo.css',false,'1.1','all');
  191.  
  192. wp_enqueue_style( 'jquery-ui', get_site_url().'/wp-content/plugins/link_Ex/css/jquery-ui.css',false,'1.1','all');
  193.  
  194.  
  195.  
  196. // wp_enqueue_script( 'jquery.dataTables', get_site_url().'/wp-content/plugins/link_Ex/js/jquery.dataTables.js', array ( 'jquery' ), 1.1, false);
  197. wp_enqueue_script( 'jquery.dataTables', get_site_url().'/wp-content/plugins/link_Ex/js/jquery.dataTables.js');
  198. wp_enqueue_script( 'dataTables.material', get_site_url().'/wp-content/plugins/link_Ex/js/dataTables.material.js', array ( 'jquery' ), 1.1, false);
  199. wp_enqueue_script( 'demo', get_site_url().'/wp-content/plugins/link_Ex/js/demo.js', array ( 'jquery' ), 1.1, false);
  200. wp_enqueue_script( 'shCore', get_site_url().'/wp-content/plugins/link_Ex/js/shCore.js', array ( 'jquery' ), 1.1, false);
  201.  
  202. wp_enqueue_script( 'jquery-ui', get_site_url().'/wp-content/plugins/link_Ex/js/jquery-ui.js', array ( 'jquery' ), 1.1, false);
  203.  
  204. if (condition): ?>
  205.  
  206. <script src="external/jquery/jquery.js"></script>
  207. <script src="jquery-ui.js"></script>
  208. <link href="jquery-ui.css" rel="stylesheet">
  209.  
  210.  
  211.  
  212.  
  213.  
  214. <meta charset="utf-8">
  215. <meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
  216. <!--<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/material-design-lite/1.1.0/material.min.css">-->
  217.  
  218. <script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.12.4.js">
  219. </script>
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227. <script type="text/javascript" language="javascript" class="init">
  228.  
  229. $(document).ready(function() {
  230. var n='';
  231. var user_id = '';
  232. $( "#dialog" ).dialog({
  233.  
  234. autoOpen: false,
  235. width: 400,
  236. buttons: [
  237. /* {
  238. text: "Ok",
  239. click: function() {
  240. var pa = $('.pa'+n).text();
  241. var da = $('.da'+n).text();
  242. var sitename = $('.sitename'+n).text();
  243. var url = $('.url'+n).text();
  244. var niche = $('.niche'+n).text();
  245.  
  246. var sender_email = $('.sender_email').val();
  247. var sender_name = $('.sender_name').val();
  248. var sender_domain = $('.sender_domain').val();
  249. //$( this ).dialog( "close" );
  250. data = {
  251. 'sender_email':sender_email,
  252. 'sender_name':sender_name,
  253. 'sender_domain':sender_domain,
  254. 'receiver_id':user_id
  255. }
  256. $.post(
  257. 'wp-content/plugins/link_Ex/link_Ex.php',
  258. {
  259. 'action': 'add_foo',
  260. 'data': data
  261. },
  262. function(response){
  263. alert('The server responded: ' + response);
  264. }
  265. );
  266.  
  267. //$( this ).dialog( "close" );
  268.  
  269. //alert(user_id);
  270. }
  271. },*/
  272. {
  273. text: "Cancel",
  274. click: function() {
  275. $( this ).dialog( "close" );
  276. }
  277. }
  278. ]
  279. });
  280.  
  281. // Link to open the dialog
  282. $( ".dialog-link" ).click(function( event ) {
  283. n = $(this).attr('n');
  284. var receiver_domain = $(this).attr("receiver-domain");
  285. $('.receiver-domain').val(receiver_domain);
  286. user_id = $(this).attr('user_id');
  287. $('.user_id_id').val(user_id);
  288.  
  289. $('.comprar_id').val(user_id);
  290.  
  291. $( "#dialog" ).dialog( "open" );
  292. event.preventDefault();
  293. });
  294.  
  295.  
  296.  
  297. $('#example').DataTable( {
  298. columnDefs: [
  299. {
  300. targets: [ 0, 1, 2 ],
  301. className: 'mdl-data-table__cell--non-numeric'
  302. }
  303. ]
  304. } );
  305.  
  306.  
  307. $('.ex_show').click(function(){
  308. $('.exchange').toggle();
  309. })
  310.  
  311. } );
  312.  
  313. </script>
  314.  
  315. <div class="dt-example dt-example-material" id='link_Ex'>
  316. <div class="container" style="">
  317. <section>
  318. <div data-role="main" class="ui-content">
  319.  
  320.  
  321. <table id="example" class="mdl-data-table" cellspacing="0" width="100%">
  322. <thead>
  323. <tr>
  324. <th>Nome do Site</th>
  325. <th>URL do Site</th>
  326. <th>PA</th>
  327. <th>DA</th>
  328. <th>Nicho</th>
  329. <th>Keyword ou Subnicho</th>
  330. <th>Trocar Link</th>
  331. </tr>
  332. </thead>
  333. <tbody>
  334. <?php
  335. $i = 0;
  336. foreach($data as $site){
  337. $sites[] = $site->website;
  338. $i++;
  339. }
  340. $x = 1;
  341. $arr = [];
  342. for($c = 0;$c<=count($sites)-1;$c++){
  343. $new10 [] = $sites[$c];
  344. if($x==10 || $c==count($sites)-1){
  345. //print_r($new10);
  346. $new10 =api($new10);
  347. foreach($new10 as $new1){
  348. $arr[] = $new1;
  349. }
  350. $new10 = [];
  351. $x = 1;
  352. }
  353. $x++;
  354. }
  355. //echo '<pre>';
  356. //print_r($arr);
  357. //echo '</pre>';
  358. $j = 0;
  359. foreach($data as $tr){
  360. $pa = round($arr[$j]->upa,1);
  361. $da = round($arr[$j]->pda,1);
  362. //print_r($sites);
  363. $i = $tr->id;
  364. $user_id = $tr->user_id;
  365. $url = $tr->website;
  366. $user_info = get_userdata($user_id);
  367. $key = $tr->keywords;
  368. echo '<tr>';
  369. echo '<td class="td sitename'.$i.'">'.$tr->name.'</td>';
  370. echo '<td class="td url'.$i.'">'.$url.'</td>';
  371. //////////////
  372. echo '<td class="td pa'.$i.'">'.$pa.'</td>';
  373. echo '<td class="td da'.$i.'">'.$da.'</td>';
  374. ///////////////
  375. echo '<td class="td niche'.$i.'">'.$tr->niche.'</td>';
  376. echo '<td class="td keywords'.$i.'">'.$key.'</td>';
  377. /////////////
  378. echo '<td class="ex td" n="'.$i.'" >';
  379.  
  380. $current_user = wp_get_current_user();
  381. $current_user_id = $current_user->ID;
  382. if(is_user_logged_in() && ($current_user_id==$user_id)) {
  383. echo '<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
  384. <input type="hidden" name="delete_id" value="'.$tr->id.'" />
  385. <button type="submit" style="background-color:red">Delete</button>
  386. </form>';
  387. }
  388. else
  389. {
  390. echo '
  391. <button receiver-domain="'.$tr->website.'" user_id="'.$user_id.'" class="dialog-link" id="dialog-link" n="'.$i.'" class="ui-button ui-corner-all ui- widget">
  392. <span class="ui-icon ui-icon-newwin"></span>Negociar</button>';
  393. }
  394.  
  395. echo '</td></tr>';
  396. $j++;
  397. }
  398.  
  399. ?>
  400. </tbody>
  401. </table>
  402.  
  403. <div id="dialog" title="Por favor, entre com os detalhes de seu site!" n="15">
  404. <button class="ex_show">Trocar link</button>
  405.  
  406.  
  407. <div class="exchange" style="display:none">
  408. <form id="dialog-form" action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post" style="border: 1px solid;padding: 10px;margin-bottom: 5px;padding-top: 60px;margin-top: -51px;">
  409. <label>Nome</label><input name='sender_name' class="sender_name" type="text"><br>
  410. <!--<label>E-mail</label><input name='sender_email' class="sender_email" type="text"><br>-->
  411. <label>Domínio para troca:</label><input name='sender_domain' class="sender_domain" type="text"><br>
  412. <input name="user_id" type="hidden" class='user_id_id'>
  413. <input name="receiver-domain" type="hidden" class="receiver-domain" />
  414. <input class="exchange" type="submit" name="exchange" value="Enviar" style="display:none"/>
  415. </form>
  416. </div>
  417.  
  418.  
  419. <form action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post">
  420. <input name='sender_name' class="sender_name" type="hidden"><br>
  421. <!--<label>E-mail</label><input name='sender_email' class="sender_email" type="text"><br>-->
  422. <input name='sender_domain' class="sender_domain" type="hidden">
  423. <input name="user_id" type="hidden" class='user_id_id'>
  424. <input name='comprar_id' class="comprar_id" type="hidden">
  425. <input class="comprar" type="hidden" name="comprar" />
  426. <input name="receiver-domain" type="hidden" class="receiver-domain" />
  427. <input type="submit" name="buy" class="buy" value="Comprar" />
  428. </form>
  429. </div>
  430.  
  431.  
  432. </section>
  433. </div>
  434. </div>
  435.  
  436. <?php else: ?>
  437. <?php endif ?>
  438. <?php
  439. }
  440.  
  441. function api($site){
  442. $accessID = "mozscape-c0c36ab22e";
  443. $secretKey = "74bd7cfb5d4dbf3f61a8050712c3d5d3";
  444. // Set your expires times for several minutes into the future.
  445. // An expires time excessively far in the future will not be honored by the Mozscape API.
  446. $expires = time() + 300;
  447. // Put each parameter on a new line.
  448. $stringToSign = $accessID."\n".$expires;
  449. // Get the "raw" or binary output of the hmac hash.
  450. $binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);
  451. // Base64-encode it and then url-encode that.
  452. $urlSafeSignature = urlencode(base64_encode($binarySignature));
  453. // Add up all the bit flags you want returned.
  454. // Learn more here: https://moz.com/help/guides/moz-api/mozscape/api-reference/url-metrics
  455. $cols = "103079215108";
  456. // Put it all together and you get your request URL.
  457. $requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
  458. // Put your URLS into an array and json_encode them.
  459. $batchedDomains = $site;
  460. $encodedDomains = json_encode($batchedDomains);
  461. // Use Curl to send off your request.
  462. // Send your encoded list of domains through Curl's POSTFIELDS.
  463. $options = array(
  464. CURLOPT_RETURNTRANSFER => true,
  465. CURLOPT_POSTFIELDS => $encodedDomains
  466. );
  467. $ch = curl_init($requestUrl);
  468. curl_setopt_array($ch, $options);
  469. $content = curl_exec($ch);
  470. curl_close( $ch );
  471. $contents = json_decode($content);
  472. $content = json_encode($content);
  473. //print_r($contents);
  474. //$contents = json_encode($contents);
  475. return $contents;
  476. }
  477.  
  478. function email() {
  479. global $website;
  480. if(isset($_POST['exchange'])){
  481. if(!empty($_POST['sender_name']) && !empty($_POST['sender_domain'])){
  482.  
  483. $sender_name = sanitize_text_field($_POST['sender_name']);
  484. //$sender_email = sanitize_text_field($_POST['sender_email']);
  485. $sender_domain = esc_url($_POST['sender_domain']);
  486. $receiver_domain = sanitize_text_field($_POST['receiver-domain']);
  487. $user_id = $_POST['user_id'] ;
  488.  
  489.  
  490. if ( !filter_var($sender_domain, FILTER_VALIDATE_URL) ) {
  491. echo '<h3>Seu domínio não é válido.</h3>';
  492. //$reg_errors->add('website', 'Website is not a valid URL');
  493. } else{
  494.  
  495. if(is_user_logged_in()) {
  496. $current_user = wp_get_current_user();
  497. $sender_email = $current_user->user_email;
  498. $receiver_info = get_userdata($user_id);
  499. $email = $receiver_info->user_email;
  500. $api = api([$sender_domain]);
  501.  
  502.  
  503. $to = $email;
  504. //change $subject to match yours.
  505. $subject = 'Você recebeu um pedido de troca de links';
  506. $headers = "From: " . strip_tags('seo@ferramentasseo.club') . "\r\n";
  507. $headers .= "Reply-To: ". strip_tags($sender_email) . "\r\n";
  508. $headers .= "MIME-Version: 1.0\r\n";
  509. $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  510. $message ='Você recebeu um pedido de troca de links. Abaixo as informações para contato: <br><br>
  511. <b>Nome</b> &nbsp;:&nbsp;'.$sender_name.'<br>
  512. <b>E-mail</b> &nbsp;:&nbsp;'.$sender_email.'<br>
  513. <b>Domínio para troca</b> &nbsp;:&nbsp;<a href="'.$sender_domain.'">'.$sender_domain.'</a><br>
  514. <b>DA</b>&nbsp;:&nbsp;'.round($api[0]->pda,1).'<br>
  515. <b>PA</b>&nbsp;:&nbsp;'.round($api[0]->upa,1).'<br>
  516. <b>Seu domínio</b>&nbsp;:&nbsp;'.$receiver_domain.'<br><br>
  517. Entre em contato para negociar a troca.';
  518. //echo $message;
  519. wp_mail($to, $subject, $message, $headers);
  520. echo '<h3>Uma mensagem de troca de link foi enviada com sucesso ao dono do domínio!</h3>';
  521. } else{
  522. echo '<h3><span style="color:red">Você não fez login. </span> <a href="' . get_site_url() . '/wp-login.php"><span style="text-decoration:underline; color:#2991d6;">Ir para a página de login</span></a>.</h3>';
  523. }
  524.  
  525.  
  526.  
  527. }
  528.  
  529.  
  530. }
  531. else{
  532. echo '<h3>Por favor preencha todos os campos.</h3>';
  533. }
  534. }
  535.  
  536. if(isset($_POST['buy'])){
  537. if(!empty($_POST['user_id'])){
  538. $receiver_domain = sanitize_text_field($_POST['receiver-domain']);
  539. $sender_name = sanitize_text_field($_POST['sender_name']);
  540. //$sender_email = sanitize_text_field($_POST['sender_email']);
  541. $sender_domain = esc_url($_POST['sender_domain']);
  542. $user_id = intval($_POST['user_id']) ;
  543.  
  544.  
  545. if(is_user_logged_in()) {
  546.  
  547. $current_user = wp_get_current_user();
  548. $sender_email = $current_user->user_email;
  549. $receiver_info = get_userdata($user_id);
  550. $email = $receiver_info->user_email;
  551. $api = api([$sender_domain]);
  552. $sender_name = $current_user->display_name;
  553.  
  554. $to = $email;
  555. $subject = 'Você recebeu um pedido de compra de links';
  556. $headers = "From: " . strip_tags('seo@ferramentasseo.club') . "\r\n";
  557. $headers .= "Reply-To: ". strip_tags($sender_email) . "\r\n";
  558. $headers .= "MIME-Version: 1.0\r\n";
  559. $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  560. $message = 'Você recebeu um pedido de compra de links. Abaixo as informações para contato:<br><br>
  561. <b>Nome</b>: '.$sender_name.'<br>
  562. <b>E-mail</b>: '.$sender_email.'<br>
  563. <b>Seu domínio</b>: '.$receiver_domain.'<br><br>
  564. Entre em contato para negociar a venda do site.';
  565. //echo '<br>COMPRAR-'.$message.'<br>'.$email;
  566. //echo $message;
  567. wp_mail($to, $subject, $message, $headers);
  568. echo '<h3>Uma mensagem de compra de link foi enviada com sucesso ao dono do domínio!</h3>';
  569. } else{
  570. echo '<h3><span style="color:red">Você não fez login. </span> <a class="linklogin" href="' . get_site_url() . '/wp-login.php"> <span style="text-decoration:underline; color:#2991d6;">Ir para a página de login</span></a>.</h3>';
  571. }
  572.  
  573.  
  574.  
  575. }
  576.  
  577.  
  578. }
  579.  
  580.  
  581.  
  582.  
  583. // Don't forget to stop execution afterward.
  584. }
  585.  
  586. function delete(){
  587. if(isset($_POST['delete_id'])){
  588. $delete_id = intval($_POST['delete_id']);
  589. echo $delete_id;
  590. global $wpdb;
  591. $table_name = $wpdb->prefix.'link_ex';
  592. $delete_item = $wpdb->get_results( "SELECT * FROM $table_name WHERE id = $delete_id" );
  593. if($delete_item){
  594. echo '<h3 style="color:red">Tem certeza que deseja deletar este domínio?</h3>
  595. <p>&nbsp;&nbsp;&nbsp;&nbsp;<b>Name</b> : '.$delete_item[0]->name.'</p>
  596. <p>&nbsp;&nbsp;&nbsp;&nbsp;<a style="text-decoration:none" href="'.$delete_item[0]->website.'">'.$delete_item[0]->website.'</a></p>
  597. <form action="'.$_SERVER['REQUEST_URI'].'" method="post">
  598. <input type="hidden" name="confirm_delete_id" value="'.$delete_item[0]->id.'" />
  599. <button type="submit" style="background-color:red">Deletar</button>
  600. </form>
  601. ';
  602. }else{
  603. echo '<h3 style="color:orange">Erro: Item Inválido!</h3>';
  604. }
  605. }
  606. confirm_delete();
  607. }
  608. function confirm_delete(){
  609. if(isset($_POST['confirm_delete_id'])){
  610. $confirm_delete_id = intval($_POST['confirm_delete_id']);
  611. global $wpdb;
  612. $table_name = $wpdb->prefix.'link_ex';
  613. $confirm_delete_id = $wpdb->delete($table_name, array('id' => $confirm_delete_id ));
  614. if($confirm_delete_id){
  615. echo '<h2 style="color:green">Domínio deletado com sucesso!</h2>';
  616. }else{
  617. echo '<h3 style="color:red">Error: Inválido domínio a ser deletado!</h3>';
  618. }
  619. }
  620. }
  621. ///////////////////////////////////////////////////
  622.  
  623. function install(){
  624. global $wpdb;
  625. $table_name = $wpdb->prefix.'link_ex';
  626. if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
  627. //table not in database. Create new table
  628. $charset_collate = $wpdb->get_charset_collate();
  629.  
  630. $sql = "CREATE TABLE $table_name (
  631. id int(5) NOT NULL AUTO_INCREMENT,
  632. user_id int(5) NOT NULL,
  633. name varchar(40) NOT NULL,
  634. website varchar(50) NOT NULL,
  635. niche varchar(40) NOT NULL,
  636. keywords text NOT NULL,
  637. PRIMARY KEY (id)
  638. ) $charset_collate;";
  639. require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
  640. dbDelta( $sql );
  641. print_r(dbDelta( $sql ));
  642. }
  643. else{
  644. }
  645. }
  646.  
  647. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  648. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  649. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  650.  
  651.  
  652. //////////////////////////////////////////////////
  653. // Register a new shortcode: [cr_link_EX]
  654. add_shortcode('LE_link_Ex', 'link_EX_shortcode');
  655.  
  656. // The callback function that will replace [book]
  657. function link_EX_shortcode() {
  658. ob_start();
  659. link_EX_function();
  660. return ob_get_clean();
  661. }
  662.  
  663. ////////////////////////////////////////////////
  664. //////////////////////////////////////////////////
  665. // Register a new shortcode: [cr_link_EX]
  666. add_shortcode('LE_link_Ex_Table', 'link_EX_Table_shortcode');
  667.  
  668.  
  669. // The callback function that will replace [book]
  670. function link_EX_Table_shortcode() {
  671. html();
  672. }
Add Comment
Please, Sign In to add comment