Plugin Directory

Changeset 3289054


Ignore:
Timestamp:
05/07/2025 10:34:12 AM (11 months ago)
Author:
topirank
Message:

Init version 2.0.1

Location:
topirank-integration
Files:
42 added
7 edited

Legend:

Unmodified
Added
Removed
  • topirank-integration/trunk/admin/admin-page.php

    r3286404 r3289054  
    109109                </div>
    110110            <?php } ?>
     111            <div class="topirank_version">
     112                <?php
     113                $plugin_data = get_plugin_data(plugin_dir_path(dirname(__FILE__)) . 'topirank-integration.php');
     114                echo esc_html(sprintf('Version %s', $plugin_data['Version']));
     115                ?>
     116            </div>
    111117        </div>
     118
     119
    112120    </div>
    113121
     
    146154            }
    147155
    148             setInterval(updateServerStatus, 5000);
    149156            updateServerStatus();
    150157        });
    151158    </script>
    152 
    153     <style>
    154         .topirank_wrap .server-status-container {
    155             display: flex;
    156             align-items: center;
    157             gap: 10px;
    158         }
    159 
    160         .topirank_wrap .server-status-indicator {
    161             width: 12px;
    162             height: 12px;
    163             border-radius: 50%;
    164             display: inline-block;
    165         }
    166 
    167         .topirank_wrap .server-status-indicator.ready {
    168             background-color: #46b450;
    169         }
    170 
    171         .topirank_wrap .server-status-indicator.not-ready {
    172             background-color: #dc3232;
    173         }
    174 
    175         .topirank_wrap .server-status-text {
    176             font-weight: 500;
    177         }
    178 
    179         .topirank_wrap .button:disabled,
    180         .topirank_wrap .topirank_solid_button:disabled,
    181         .topirank_wrap .topirank_outline_button:disabled {
    182             opacity: 0.7;
    183             cursor: not-allowed;
    184         }
    185     </style>
    186159<?php
    187160}
  • topirank-integration/trunk/assets/css/topirank-admin-style.css

    r3220350 r3289054  
    6161}
    6262.topirank_wrap {
     63  display: flex;
     64  flex-direction: column;
    6365  padding: 16px 32px;
    6466  border-radius: 12px;
     
    274276  margin-bottom: 4px;
    275277}
     278
     279.topirank_wrap .server-status-container {
     280  display: flex;
     281  align-items: center;
     282  gap: 10px;
     283}
     284
     285.topirank_wrap .server-status-indicator {
     286  width: 12px;
     287  height: 12px;
     288  border-radius: 50%;
     289  display: inline-block;
     290}
     291
     292.topirank_wrap .server-status-indicator.ready {
     293  background-color: #46b450;
     294}
     295
     296.topirank_wrap .server-status-indicator.not-ready {
     297  background-color: #dc3232;
     298}
     299
     300.topirank_wrap .server-status-text {
     301  font-weight: 500;
     302}
     303
     304.topirank_wrap .button:disabled,
     305.topirank_wrap .topirank_solid_button:disabled,
     306.topirank_wrap .topirank_outline_button:disabled {
     307  opacity: 0.7;
     308  cursor: not-allowed;
     309}
     310
     311.topirank_version {
     312  text-align: right;
     313  margin-top: auto;
     314  font-size: 12px;
     315  color: #666;
     316  padding: 5px 10px;
     317}
  • topirank-integration/trunk/includes/batch-processor.php

    r3286408 r3289054  
    100100
    101101      $start = $this->current_batch * $this->batch_size;
    102       $end = min($start + $this->batch_size, $this->total_files);
    103102
    104103      $batch_files = array_slice($this->files_to_process, $start, $this->batch_size);
     
    220219          }
    221220
    222           usleep(500000);
     221          usleep(100000);
    223222        }
    224223
     
    247246          $final_messages = $batch_messages;
    248247          $final_conflicts = $this->conflicts;
     248
     249          do_action('topirank_after_last_batch');
    249250
    250251          $final_progress = array(
     
    469470        }
    470471
    471         usleep(500000);
     472        usleep(100000);
    472473      }
    473474
     
    499500        $final_conflicts = $this->conflicts;
    500501
     502        do_action('topirank_after_last_batch');
     503
    501504        $final_progress = array(
    502505          'processed' => $final_processed,
  • topirank-integration/trunk/includes/topirank-template.php

    r3286439 r3289054  
    33if (! defined('ABSPATH')) exit;
    44/* Template Name: Topirank Post Template */
    5 /* Template Post Type: post */
     5/* Template Post Type: post, page */
    66if (is_user_logged_in()) {
    77    show_admin_bar(false);
  • topirank-integration/trunk/includes/update-content-and-seo.php

    r3286404 r3289054  
    341341  }
    342342}
     343
     344function topirank_update_all_post_links()
     345{
     346  $args = array(
     347    'post_type' => 'page',
     348    'post_status' => 'publish',
     349    'posts_per_page' => -1,
     350  );
     351
     352  $query = new WP_Query($args);
     353
     354  if (!$query->have_posts()) {
     355    return;
     356  }
     357
     358  foreach ($query->posts as $post) {
     359    $content = $post->post_content;
     360
     361    libxml_use_internal_errors(true);
     362    $dom = new DOMDocument('1.0', 'UTF-8');
     363    $dom->preserveWhiteSpace = false;
     364    $dom->formatOutput = true;
     365
     366    $content = '<?xml encoding="UTF-8">' . $content;
     367    $dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NOWARNING);
     368    libxml_clear_errors();
     369
     370    $xpath = new DOMXPath($dom);
     371    $links = $xpath->query('//a[@href]');
     372    $link_slugs = [];
     373    $link_elements = [];
     374
     375    foreach ($links as $link) {
     376      $href = $link->getAttribute('href');
     377      if (preg_match('/^(?:\.\.\/)+(.+)\/index\.html$/iu', $href, $matches)) {
     378        $encoded_url = $matches[1];
     379        $decoded_url = urldecode($encoded_url);
     380        $slug = basename($decoded_url);
     381
     382        if (!empty($slug)) {
     383          $link_slugs[] = $slug;
     384          $link_elements[] = $link;
     385        }
     386      }
     387    }
     388
     389    $unique_slugs = array_unique($link_slugs);
     390    $slug_to_post = [];
     391
     392
     393    if (!empty($unique_slugs)) {
     394      foreach ($unique_slugs as $unique_slug) {
     395        $post_query = new WP_Query([
     396          'name' => $unique_slug,
     397          'post_type' => 'page',
     398          'post_status' => 'publish',
     399          'fields' => 'ids',
     400          'posts_per_page' => 1,
     401        ]);
     402
     403        $found_post_id = !empty($post_query->posts) ? $post_query->posts[0] : null;
     404        if ($found_post_id) {
     405          $slug_to_post[$unique_slug] = get_permalink($found_post_id);
     406        }
     407        wp_reset_postdata();
     408      }
     409    }
     410
     411
     412    $content_updated = false;
     413    foreach ($link_elements as $index => $link) {
     414      $formatted_slug = $link_slugs[$index];
     415      if (isset($slug_to_post[$formatted_slug])) {
     416        $link->setAttribute('href', $slug_to_post[$formatted_slug]);
     417        $content_updated = true;
     418      }
     419    }
     420
     421    if ($content_updated) {
     422      $new_content = preg_replace('/<\?xml[^>]+>/', '', $dom->saveHTML());
     423      $new_content = preg_replace('/<head\b[^>]*>.*?<\/head>/is', '', $new_content);
     424
     425      $content_filters = $GLOBALS['wp_filter']['content_save_pre'] ?? null;
     426      $content_filtered_filters = $GLOBALS['wp_filter']['content_filtered_save_pre'] ?? null;
     427      $the_content_filters = $GLOBALS['wp_filter']['the_content'] ?? null;
     428      $the_editor_content_filters = $GLOBALS['wp_filter']['the_editor_content'] ?? null;
     429      $tiny_mce_filters = $GLOBALS['wp_filter']['tiny_mce_before_init'] ?? null;
     430
     431      remove_filter('content_save_pre', 'wp_filter_post_kses');
     432      remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
     433      remove_all_filters('the_content');
     434      remove_all_filters('the_editor_content');
     435      remove_all_filters('tiny_mce_before_init');
     436
     437      wp_update_post(array(
     438        'ID' => $post->ID,
     439        'post_content' => $new_content
     440      ));
     441
     442      if ($content_filters) {
     443        $GLOBALS['wp_filter']['content_save_pre'] = $content_filters;
     444      }
     445      if ($content_filtered_filters) {
     446        $GLOBALS['wp_filter']['content_filtered_save_pre'] = $content_filtered_filters;
     447      }
     448      if ($the_content_filters) {
     449        $GLOBALS['wp_filter']['the_content'] = $the_content_filters;
     450      }
     451      if ($the_editor_content_filters) {
     452        $GLOBALS['wp_filter']['the_editor_content'] = $the_editor_content_filters;
     453      }
     454      if ($tiny_mce_filters) {
     455        $GLOBALS['wp_filter']['tiny_mce_before_init'] = $tiny_mce_filters;
     456      }
     457    }
     458  }
     459
     460  wp_reset_postdata();
     461}
     462
     463add_action('topirank_after_last_batch', 'topirank_update_all_post_links');
  • topirank-integration/trunk/readme.txt

    r3286404 r3289054  
    44Requires at least: 6.0
    55Tested up to: 6.8
    6 Stable tag: 2.0
     6Stable tag: 2.0.1
    77Requires PHP: 7.3
    88License: GPLv2 or later
     
    6666
    6767== Changelog ==
     68
     69= 2.0.1 =
     70- Added version display.
     71- Fixed problem with internal links.
     72- Fixed problem with API requests.
    6873
    6974= 2.0 =
  • topirank-integration/trunk/topirank-integration.php

    r3286404 r3289054  
    33Plugin Name: Topirank Integration
    44Description: Plugin for parsing pages
    5 Version: 2.0
     5Version: 2.0.1
    66Author: Topirank
    77License: GPLv2 or later
     
    2525require_once plugin_dir_path(__FILE__) . 'includes/file-upload.php';
    2626require_once plugin_dir_path(__FILE__) . 'includes/extract-and-create.php';
    27 require_once plugin_dir_path(__FILE__) . 'includes/process-folders.php';
    2827require_once plugin_dir_path(__FILE__) . 'includes/helpers.php';
    2928require_once plugin_dir_path(__FILE__) . 'includes/api-integration.php';
     
    3130require_once plugin_dir_path(__FILE__) . 'includes/register-files.php';
    3231require_once plugin_dir_path(__FILE__) . 'includes/update-functionality.php';
     32require_once plugin_dir_path(__FILE__) . 'includes/version-endpoint.php';
    3333
    3434register_activation_hook(__FILE__, 'topirank_generate_random_token');
Note: See TracChangeset for help on using the changeset viewer.