Changeset 2981703
- Timestamp:
- 10/20/2023 01:07:20 PM (2 years ago)
- Location:
- outranking/trunk
- Files:
-
- 2 added
- 5 edited
-
README.txt (modified) (2 diffs)
-
api (added)
-
api/api.php (added)
-
changelog.txt (modified) (1 diff)
-
inc/ajax.php (modified) (1 diff)
-
inc/core.php (modified) (2 diffs)
-
outranking.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
outranking/trunk/README.txt
r2940266 r2981703 5 5 Tested up to: 6.1.1 6 6 Requires PHP: 5.6 7 Stable tag: 1.0. 67 Stable tag: 1.0.5 8 8 License: GNU General Public License v3 or later 9 9 License URL: https://www.gnu.org/licenses/gpl-3.0.en.html … … 43 43 - Added Support for Unicode characters while importing and exporting 44 44 45 = v1.0.6 : Jul 192023 =45 = v1.0.6 : Jul 05 2023 = 46 46 - Added Support for iframes and youtube videos 47 47 - Fixed an issue with TinyMCE 48 49 = v1.1.0 : Aug 31 2023 = 50 - Added API Support for Creating, Updating and Selective Updating of a Post 51 52 = v1.1.1 : Sep 22 2023 = 53 - Optimization and Integration of API with Outranking Portal 54 55 = v1.1.2 : Sep 22 2023 = 56 - Content filteration for image, iframe and anchor tag -
outranking/trunk/changelog.txt
r2940266 r2981703 27 27 - Added Support for Unicode characters while importing and exporting 28 28 29 ===== v1.0.6 : Jul 192023 =====29 ===== v1.0.6 : Jul 05 2023 ===== 30 30 - Added Support for iframes and youtube videos 31 31 - Fixed an issue with TinyMCE 32 33 ===== v1.1.0 : Aug 31 2023 ===== 34 - Added API Support for Creating, Updating and Selective Updating of a Post 35 36 ===== v1.1.1 : Sep 22 2023 ===== 37 - Optimization and Integration of API with Outranking Portal 38 39 ===== v1.1.2 : Sep 22 2023 ===== 40 - Content filteration for image, iframe and anchor tag -
outranking/trunk/inc/ajax.php
r2940265 r2981703 76 76 $outranking_document_id = sanitize_text_field($_POST['id']); 77 77 $article = OutrankingMetaBox::import($outranking_document_id); 78 /** 79 * Added support for custom tags, specially for videos, allowed iframe to be included in the content 80 * Added support for nofollow and sponsored attributes in the a tag 81 * @since 1.0.6 82 */ 83 $allowed_html = wp_kses_allowed_html('post'); 84 $allowed_html['iframe'] = array( 85 'class' => 1, 86 'frameborder' => 1, 87 'allowfullscreen' => 1, 88 'src' => 1, 89 ); 90 91 $allowed_html['a']['nofollow'] = 1; 92 $allowed_html['a']['rel'] = 1; 93 94 95 $article->content = wp_kses($article->content, $allowed_html); 96 /** 97 * Processing images into the post and uploading it to the wordpress site 98 * and replace the outranking URLs with the local ones. 99 * @since 1.0.2 100 */ 101 $document = new DOMDocument(); 102 $document->loadHTML(mb_convert_encoding($article->content, 'HTML-ENTITIES', 'UTF-8')); 103 $images = $document->getElementsByTagName('img'); 104 $a_tags = $document->getElementsByTagName('a'); 105 foreach ($images as $key => $image) { 106 $src = $image->getAttribute('src'); 107 $new_src = outranking_upload_image($src); 108 /** 109 * Replaced the function from createElement and setAttribute to cloneNode to get all the attributes along with it 110 * $new_img = $document->createElement('img'); 111 * $new_img->setAttribute('alt', $image->getAttribute('alt')); 112 * @since 1.0.6 113 */ 114 $new_img = $image->cloneNode(true); 115 $new_img->setAttribute('src', $new_src); 116 $image->parentNode->replaceChild($new_img, $image); 117 } 118 $iframes = $document->getElementsByTagName('iframe'); 119 /** 120 * Processing iframes into the post and replacing regular youtube URLs to embed ones 121 * @since 1.0.2 122 */ 123 foreach ($iframes as $iframe) { 124 $src = $iframe->getAttribute('src'); 125 $src = str_replace("https://www.youtube.com/watch?v=", "https://www.youtube.com/embed/", $src); 126 $src = str_replace("https://youtu.be/", "https://www.youtube.com/embed/", $src); 127 $new_iframe = $iframe->cloneNode(true); 128 $new_iframe->setAttribute('src', $src); 129 $iframe->parentNode->replaceChild($new_iframe, $iframe); 130 } 131 /** 132 * Processing a into the post and add rel="nofollow" to the external links. 133 * @since 1.0.2 134 */ 135 foreach ($a_tags as $a_tag) { 136 $key = site_url(); 137 if (!is_numeric(stripos($a_tag->getAttribute('href'), $key))) { 138 if ($a_tag->hasAttribute('rel') and ($rel_att = $a_tag->getAttribute('rel')) !== '') { 139 $rel = preg_split('/\s+/', trim($rel_att)); 140 } 141 if (!in_array('nofollow', $rel)) { 142 $rel[] = 'nofollow'; 143 $a_tag->setAttribute('rel', implode(' ', $rel)); 144 } 145 } 146 } 147 $article->content = $document->saveHTML(); 78 /** 79 * Converted into function 80 * @since 1.1.2 81 */ 82 // /** 83 // * Added support for custom tags, specially for videos, allowed iframe to be included in the content 84 // * Added support for nofollow and sponsored attributes in the a tag 85 // * @since 1.0.6 86 // */ 87 // $allowed_html = wp_kses_allowed_html('post'); 88 // $allowed_html['iframe'] = array( 89 // 'class' => 1, 90 // 'frameborder' => 1, 91 // 'allowfullscreen' => 1, 92 // 'src' => 1, 93 // ); 94 95 // $allowed_html['a']['nofollow'] = 1; 96 // $allowed_html['a']['rel'] = 1; 97 98 99 // $article->content = wp_kses($article->content, $allowed_html); 100 // /** 101 // * Processing images into the post and uploading it to the wordpress site 102 // * and replace the outranking URLs with the local ones. 103 // * @since 1.0.2 104 // */ 105 // $document = new DOMDocument(); 106 // $document->loadHTML(mb_convert_encoding($article->content, 'HTML-ENTITIES', 'UTF-8')); 107 // $images = $document->getElementsByTagName('img'); 108 // $a_tags = $document->getElementsByTagName('a'); 109 // foreach ($images as $key => $image) { 110 // $src = $image->getAttribute('src'); 111 // $new_src = outranking_upload_image($src); 112 // /** 113 // * Replaced the function from createElement and setAttribute to cloneNode to get all the attributes along with it 114 // * $new_img = $document->createElement('img'); 115 // * $new_img->setAttribute('alt', $image->getAttribute('alt')); 116 // * @since 1.0.6 117 // */ 118 // $new_img = $image->cloneNode(true); 119 // $new_img->setAttribute('src', $new_src); 120 // $image->parentNode->replaceChild($new_img, $image); 121 // } 122 // $iframes = $document->getElementsByTagName('iframe'); 123 // /** 124 // * Processing iframes into the post and replacing regular youtube URLs to embed ones 125 // * @since 1.0.2 126 // */ 127 // foreach ($iframes as $iframe) { 128 // $src = $iframe->getAttribute('src'); 129 // $src = str_replace("https://www.youtube.com/watch?v=", "https://www.youtube.com/embed/", $src); 130 // $src = str_replace("https://youtu.be/", "https://www.youtube.com/embed/", $src); 131 // $new_iframe = $iframe->cloneNode(true); 132 // $new_iframe->setAttribute('src', $src); 133 // $iframe->parentNode->replaceChild($new_iframe, $iframe); 134 // } 135 // /** 136 // * Processing a into the post and add rel="nofollow" to the external links. 137 // * @since 1.0.2 138 // */ 139 // foreach ($a_tags as $a_tag) { 140 // $key = site_url(); 141 // if (!is_numeric(stripos($a_tag->getAttribute('href'), $key))) { 142 // if ($a_tag->hasAttribute('rel') and ($rel_att = $a_tag->getAttribute('rel')) !== '') { 143 // $rel = preg_split('/\s+/', trim($rel_att)); 144 // } 145 // if (!in_array('nofollow', $rel)) { 146 // $rel[] = 'nofollow'; 147 // $a_tag->setAttribute('rel', implode(' ', $rel)); 148 // } 149 // } 150 // } 151 // $article->content = $document->saveHTML(); 152 153 /** 154 * Filter the content 155 * @since 1.1.2 156 */ 157 $article->content = outranking_content_filter($article->content); 158 148 159 /** 149 160 * Show Meta Title and Meta Description in side panel for copy. -
outranking/trunk/inc/core.php
r2725947 r2981703 1 1 <?php 2 3 if (!function_exists('download_url')) { 4 include_once(ABSPATH . '/wp-admin/includes/file.php'); 5 } 6 if (!function_exists('media_handle_sideload')) { 7 include_once(ABSPATH . '/wp-admin/includes/image.php'); 8 include_once(ABSPATH . '/wp-admin/includes/media.php'); 9 } 10 if (!function_exists('wp_get_attachment_url')) { 11 include_once(ABSPATH . '/wp-includes/post.php'); 12 } 2 13 /** 3 14 * Function to Upload Image To Media Library From External URL … … 28 39 return $image; 29 40 } 41 /** 42 * Added a common function to filter the content coming from Outranking Platform which will replace the images with locally hosted images, 43 * change the youtube video to embed 44 * @since 1.1.2 45 */ 46 function outranking_content_filter($content) 47 { 48 49 $allowed_html = wp_kses_allowed_html('post'); 50 $allowed_html['iframe'] = array( 51 'class' => 1, 52 'frameborder' => 1, 53 'allowfullscreen' => 1, 54 'src' => 1, 55 ); 56 57 $allowed_html['a']['nofollow'] = 1; 58 $allowed_html['a']['rel'] = 1; 59 60 $content = wp_kses($content, $allowed_html); 61 62 $document = new DOMDocument(); 63 $document->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8')); 64 $images = $document->getElementsByTagName('img'); 65 $a_tags = $document->getElementsByTagName('a'); 66 67 foreach ($images as $key => $image) { 68 69 $src = $image->getAttribute('src'); 70 $new_src = __NAMESPACE__ . outranking_upload_image($src); 71 72 /** 73 * Replaced the function from createElement and setAttribute to cloneNode to get all the attributes along with it 74 * $new_img = $document->createElement('img'); 75 * $new_img->setAttribute('alt', $image->getAttribute('alt')); 76 * @since 1.0.6 77 */ 78 $new_img = $image->cloneNode(true); 79 $new_img->setAttribute('src', $new_src); 80 $image->parentNode->replaceChild($new_img, $image); 81 } 82 $iframes = $document->getElementsByTagName('iframe'); 83 /** 84 * Processing iframes into the post and replacing regular youtube URLs to embed ones 85 * @since 1.0.2 86 */ 87 foreach ($iframes as $iframe) { 88 $src = $iframe->getAttribute('src'); 89 echo $src; 90 $src = str_replace("https://www.youtube.com/watch?v=", "https://www.youtube.com/embed/", $src); 91 $src = str_replace("https://youtu.be/", "https://www.youtube.com/embed/", $src); 92 echo $src; 93 $new_iframe = $iframe->cloneNode(true); 94 $new_iframe->setAttribute('src', $src); 95 $iframe->parentNode->replaceChild($new_iframe, $iframe); 96 } 97 98 /** 99 * Processing a into the post and add rel="nofollow" to the external links. 100 * @since 1.0.2 101 */ 102 foreach ($a_tags as $a_tag) { 103 $key = site_url(); 104 if (!is_numeric(stripos($a_tag->getAttribute('href'), $key))) { 105 if ($a_tag->hasAttribute('rel') and ($rel_att = $a_tag->getAttribute('rel')) !== '') { 106 $rel = preg_split('/\s+/', trim($rel_att)); 107 } 108 if (!in_array('nofollow', $rel)) { 109 $rel[] = 'nofollow'; 110 $a_tag->setAttribute('rel', implode(' ', $rel)); 111 } 112 } 113 } 114 115 return $document->saveHTML(); 116 } -
outranking/trunk/outranking.php
r2940265 r2981703 3 3 Plugin Name: Outranking 4 4 Description: Outranking Extension for WordPress 5 Version: 1. 0.65 Version: 1.1.2 6 6 Author: Outranking LLC 7 7 Author URI: https://www.outranking.io/ … … 26 26 include_once(__DIR__ . '/inc/core.php'); 27 27 include_once(__DIR__ . '/inc/ajax.php'); 28 /** 29 * Included API file 30 * @since 1.1.0 31 */ 32 include_once(__DIR__ . '/api/api.php'); 28 33 /** 29 34 * Registering Metabox in Post to display list of articles to import and export
Note: See TracChangeset
for help on using the changeset viewer.