Plugin Directory

Changeset 3249873


Ignore:
Timestamp:
03/03/2025 05:49:42 PM (13 months ago)
Author:
topirank
Message:

Init version 1.1

Location:
topirank-integration
Files:
32 added
7 edited

Legend:

Unmodified
Added
Removed
  • topirank-integration/trunk/assets/css/topirank-normalize.css

    r3234611 r3249873  
    2828  padding: 10px;
    2929  border-radius: 20px !important;
     30}
     31
     32.wordpress-styles .second-container .input-container #reply-to-id-clear {
     33  right: 0;
     34  width: 24px;
     35  font-size: 18px;
     36}
     37
     38.wordpress-styles .quiz-form .input-group input[type="radio"] + label {
     39  margin-bottom: 0;
    3040}
    3141
     
    6272}
    6373
     74.wordpress-styles
     75  div[class*="Author_authorContainer__"]
     76  > div:last-of-type
     77  > div {
     78  margin-right: 15px;
     79  display: flex;
     80  flex-direction: column;
     81  justify-content: center;
     82  align-items: center;
     83}
     84
    6485#show-comments p {
    6586  margin-bottom: 0 !important;
     
    6889.optimized-topirank-template ul {
    6990  margin: 0;
     91}
     92
     93.response-content p {
     94  margin-bottom: 0;
     95}
     96
     97.topirank-styles h2 {
     98  margin: 0;
     99}
     100
     101.topirank-styles figcaption {
     102  font-style: normal;
     103}
     104
     105.topirank-styles .buttonCtaFirst button {
     106  border: 0;
    70107}
    71108
  • topirank-integration/trunk/includes/extract-and-create.php

    r3243456 r3249873  
    216216                '*',
    217217                'textarea',
    218                 'input',
    219218                '.faqContainer .faqQuestion',
    220219                '.container-comment button',
     
    327326
    328327                if ($wp_filesystem->exists($font_file_path)) {
    329                     $new_src = trailingslashit($fonts_url) . $font_file_name;
     328                    $new_src = '"' . trailingslashit($fonts_url) . $font_file_name . '"';
    330329
    331330                    if (strpos($css_content, $font_src) !== false) {
  • topirank-integration/trunk/includes/helpers.php

    r3236026 r3249873  
    6060            }
    6161
     62            $directory_name = basename(dirname($file->getPathname()));
     63
    6264            $post_id = wp_insert_post([
    6365                'post_title'   => $unique_title,
     
    6567                'post_status'  => 'publish',
    6668                'post_type'    => 'page',
    67                 'post_name'    => sanitize_title($article_title),
     69                'post_name'    => sanitize_title($directory_name),
    6870            ]);
    6971
  • topirank-integration/trunk/includes/register-files.php

    r3236026 r3249873  
    117117    if (is_dir($js_path)) {
    118118        $js_files = glob($js_path . '/*.js');
    119         $matched_files = [];
     119
     120        $current_slug = sanitize_title($post->post_name);
    120121
    121122        foreach ($js_files as $js_file) {
     
    123124            $file_name = str_replace('-script', '', $file_name);
    124125
    125             if (strpos($file_name, '-page-') !== false) {
    126                 $file_slug = explode('-page-', $file_name)[1];
    127 
    128                 if (in_array($file_slug, $post_slugs, true)) {
    129                     $matched_files[$file_slug] = $js_file;
    130                 } else {
    131                     wp_enqueue_script(
    132                         'topirank-archive-js-' . sanitize_title($file_name),
    133                         $js_url . '/' . basename($js_file),
    134                         [],
    135                         time(),
    136                         true
    137                     );
     126            $slug_pos = strpos($file_name, $current_slug);
     127
     128            if ($slug_pos === 0) {
     129                $file_name = substr_replace($file_name, '', $slug_pos, strlen($current_slug));
     130                $page_pos = strpos($file_name, '-page-');
     131                if ($page_pos !== false) {
     132                    $file_name = substr_replace($file_name, '', $page_pos, 6);
    138133                }
    139             } else {
    140                 wp_enqueue_script(
    141                     'topirank-archive-js-' . sanitize_title($file_name),
    142                     $js_url . '/' . basename($js_file),
    143                     [],
    144                     time(),
    145                     true
    146                 );
     134
     135                if (strpos($file_name, $current_slug) === false) {
     136                    continue;
     137                }
    147138            }
    148         }
    149 
    150         $current_post_slug = $post->post_name;
    151         if (isset($matched_files[$current_post_slug])) {
     139
    152140            wp_enqueue_script(
    153                 'topirank-archive-js-' . sanitize_title($current_post_slug),
    154                 $js_url . '/' . basename($matched_files[$current_post_slug]),
     141                'topirank-archive-js-' . sanitize_title($file_name),
     142                $js_url . '/' . basename($js_file),
    155143                [],
    156144                time(),
     
    160148    }
    161149}
     150
     151
    162152
    163153function topirank_admin_styles_for_special_template($hook)
  • topirank-integration/trunk/includes/update-content-and-seo.php

    r3243456 r3249873  
    111111      $container->removeAttribute('style');
    112112
    113       $remove_styles = function ($elements, $properties) use ($dom) {
    114         foreach ($elements as $element) {
    115           if ($element instanceof DOMElement && $element->hasAttribute('style')) {
    116             $style = $element->getAttribute('style');
    117             $pattern = '/(?:^|;)\s*(' . implode('|', $properties) . ')\s*:\s*[^;]+;?/i';
    118             $filtered_style = preg_replace($pattern, '', $style);
    119             $filtered_style = trim($filtered_style, " \t\n\r\0\x0B;");
    120 
    121             if (!empty($filtered_style)) {
    122               $element->setAttribute('style', $filtered_style);
    123             } else {
    124               $element->removeAttribute('style');
    125             }
    126           }
    127         }
    128       };
    129 
    130       $div_elements = $xpath->query('.//div[@style]', $container);
    131       $remove_styles($div_elements, ['color']);
    132 
    133       $elements_with_style = $xpath->query('.//*[@style]', $container);
    134       $remove_styles($elements_with_style, ['color', 'background-color', 'accent-color', 'font-size', 'line-height']);
     113      $divElements = $xpath->query('.//div[@style]', $container);
     114      removeStyles($divElements, ['color']);
     115
     116      $elementsWithStyle = $xpath->query('.//*[@style]', $container);
     117      removeStyles($elementsWithStyle, ['color', 'background-color', 'accent-color', 'font-size', 'line-height']);
     118
    135119
    136120      $content = preg_replace('/color\s*:\s*[^;"]+;?/i', '', $content);
     
    255239}
    256240
     241function removeStyles(DOMNodeList $elements, array $properties)
     242{
     243  $properties = array_map('strtolower', $properties);
     244
     245  foreach ($elements as $element) {
     246    if (!$element instanceof DOMElement) {
     247      continue;
     248    }
     249    $styleAttr = $element->getAttribute('style');
     250    $declarations = array_filter(array_map('trim', explode(';', $styleAttr)));
     251    $filteredDeclarations = [];
     252
     253    foreach ($declarations as $declaration) {
     254      if (strpos($declaration, ':') !== false) {
     255        list($property, $value) = array_map('trim', explode(':', $declaration, 2));
     256        if (!in_array(strtolower($property), $properties, true)) {
     257          $filteredDeclarations[] = "$property: $value";
     258        }
     259      }
     260    }
     261
     262    if ($filteredDeclarations) {
     263      $element->setAttribute('style', implode('; ', $filteredDeclarations));
     264    } else {
     265      $element->removeAttribute('style');
     266    }
     267  }
     268}
     269
    257270function topirank_assign_author_to_post($post_id, $author_name)
    258271{
  • topirank-integration/trunk/readme.txt

    r3243456 r3249873  
    44Requires at least: 6.0
    55Tested up to: 6.7.1
    6 Stable tag: 1.0.8
     6Stable tag: 1.1
    77Requires PHP: 7.3
    88License: GPLv2 or later
     
    5858== Changelog ==
    5959
     60= 1.1 =
     61* Optimized parsing.
     62* Improved compatibility with themes.
     63* Fixed issues with JS file inclusion.
     64* Enhanced font integration.
     65* Optimized theme style integration in posts.
     66
    6067= 1.0.8 =
    6168* Improved article styling.
  • topirank-integration/trunk/topirank-integration.php

    r3243456 r3249873  
    33Plugin Name: Topirank Integration
    44Description: Plugin for parsing pages
    5 Version: 1.0.8
     5Version: 1.1
    66Author: Topirank
    77License: GPLv2 or later
Note: See TracChangeset for help on using the changeset viewer.