Changeset 2427198
- Timestamp:
- 11/27/2020 10:55:57 AM (5 years ago)
- Location:
- svgator
- Files:
-
- 57 added
- 8 edited
-
tags/1.0.2 (added)
-
tags/1.0.2/admin (added)
-
tags/1.0.2/admin/css (added)
-
tags/1.0.2/admin/css/loader.svg (added)
-
tags/1.0.2/admin/css/svgator.css (added)
-
tags/1.0.2/admin/imgs (added)
-
tags/1.0.2/admin/imgs/import.svg (added)
-
tags/1.0.2/admin/imgs/loader.svg (added)
-
tags/1.0.2/admin/imgs/logout.svg (added)
-
tags/1.0.2/admin/imgs/magnifier.svg (added)
-
tags/1.0.2/admin/js (added)
-
tags/1.0.2/admin/js/WP_SVGator.js (added)
-
tags/1.0.2/admin/js/WP_SVGatorNotice.js (added)
-
tags/1.0.2/admin/js/svgator.js (added)
-
tags/1.0.2/admin/projects.php (added)
-
tags/1.0.2/admin/snippets (added)
-
tags/1.0.2/admin/snippets/empty-keys.php (added)
-
tags/1.0.2/admin/snippets/projects.php (added)
-
tags/1.0.2/includes (added)
-
tags/1.0.2/includes/autoload.php (added)
-
tags/1.0.2/includes/class (added)
-
tags/1.0.2/includes/class/WP_SVGator.php (added)
-
tags/1.0.2/includes/class/WP_SVGator_Block (added)
-
tags/1.0.2/includes/class/WP_SVGator_Block/WP_SVGator_Block.php (added)
-
tags/1.0.2/includes/class/WP_SVGator_Deactivator.php (added)
-
tags/1.0.2/includes/class/WP_SVGator_Media.php (added)
-
tags/1.0.2/includes/class/WP_SVGator_Menu.php (added)
-
tags/1.0.2/includes/class/WP_SVGator_Svg_Support.php (added)
-
tags/1.0.2/includes/class/WP_SVGator_View.php (added)
-
tags/1.0.2/index.php (added)
-
tags/1.0.2/license.txt (added)
-
tags/1.0.2/readme.txt (added)
-
tags/1.0.2/screenshot-1.png (added)
-
tags/1.0.2/sdk (added)
-
tags/1.0.2/sdk/README.md (added)
-
tags/1.0.2/sdk/autoload.php (added)
-
tags/1.0.2/sdk/class (added)
-
tags/1.0.2/sdk/class/SVGatorSDK (added)
-
tags/1.0.2/sdk/class/SVGatorSDK/Main.php (added)
-
tags/1.0.2/sdk/class/SVGatorSDK/Model (added)
-
tags/1.0.2/sdk/class/SVGatorSDK/Model/Project.php (added)
-
tags/1.0.2/sdk/class/SVGatorSDK/Projects.php (added)
-
tags/1.0.2/sdk/class/SVGatorSDK/Request.php (added)
-
tags/1.0.2/sdk/class/SVGatorSDK/Response.php (added)
-
tags/1.0.2/svgator.php (added)
-
tags/1.0.2/wp-svgator-block (added)
-
tags/1.0.2/wp-svgator-block/css (added)
-
tags/1.0.2/wp-svgator-block/css/style.css (added)
-
tags/1.0.2/wp-svgator-block/imgs (added)
-
tags/1.0.2/wp-svgator-block/imgs/loader.svg (added)
-
tags/1.0.2/wp-svgator-block/imgs/logo.svg (added)
-
tags/1.0.2/wp-svgator-block/imgs/magnifier.svg (added)
-
tags/1.0.2/wp-svgator-block/js (added)
-
tags/1.0.2/wp-svgator-block/js/SVGator_BlockProjects.js (added)
-
tags/1.0.2/wp-svgator-block/js/SVGator_BlockProjects_Popup.js (added)
-
tags/1.0.2/wp-svgator-block/js/index.js (added)
-
trunk/includes/class/WP_SVGator.php (modified) (2 diffs)
-
trunk/includes/class/WP_SVGator_Block/WP_SVGator_Block.php (modified) (1 diff)
-
trunk/includes/class/WP_SVGator_Svg_Support.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/svgator.php (modified) (2 diffs)
-
trunk/wp-svgator-block/css/style.css (modified) (3 diffs)
-
trunk/wp-svgator-block/imgs/magnifier.svg (added)
-
trunk/wp-svgator-block/js/SVGator_BlockProjects.js (modified) (4 diffs)
-
trunk/wp-svgator-block/js/SVGator_BlockProjects_Popup.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
svgator/trunk/includes/class/WP_SVGator.php
r2422334 r2427198 11 11 require $sdkAutoload; 12 12 13 // Let's not make this public yet.. We still have issues w/ it 14 //(new \WP_SVGator_Block\WP_SVGator_Block())->run(); 13 (new \WP_SVGator_Block\WP_SVGator_Block())->run(); 15 14 (new \WP_SVGator_Svg_Support())->run(); 16 15 add_action('admin_menu', [$this, 'wp_adminMenu']); … … 166 165 'success' => true, 167 166 'response' => [ 167 'id' => intval($resp['attachment']), 168 168 'html' => wp_get_attachment_image($resp['attachment']), 169 169 'url' => $resp['url'], -
svgator/trunk/includes/class/WP_SVGator_Block/WP_SVGator_Block.php
r2422334 r2427198 6 6 public function run() { 7 7 add_action('init', [$this, 'registerBlock']); 8 add_action('enqueue_block_editor_assets', [$this, 'addGutenbergScripts']);9 8 } 10 9 11 10 function registerBlock() { 11 $userId = get_current_user_id(); 12 13 if (!$userId) { 14 return; 15 } 16 17 $userTokens = get_user_option('svgator_api', $userId); 18 19 $loggedOut = empty($userTokens) 20 || empty($userTokens['app_id']) 21 || empty($userTokens['secret_key']) 22 || empty($userTokens['customer_id']) 23 || empty($userTokens['access_token']); 24 25 if ($loggedOut) { 26 return; 27 } 28 29 add_action('enqueue_block_editor_assets', [$this, 'addGutenbergScripts']); 30 12 31 register_block_type('wp-svgator/insert-svg'); 13 32 } -
svgator/trunk/includes/class/WP_SVGator_Svg_Support.php
r2422387 r2427198 26 26 27 27 $content = preg_replace_callback( 28 '/(<img .*?>)/',28 '/(<img[^>]*?>)/', 29 29 [$this, 'getImageReplacement'], 30 30 $content … … 114 114 115 115 function fixScript($svgContent) { 116 //Remove CDATA, since Wordpress does not allow it inside the content 117 $svgContent = str_replace('<![CDATA[', '', $svgContent); 118 $svgContent = str_replace(']]>', '', $svgContent); 119 116 120 $startOfScript = strpos($svgContent, '<script>'); 117 121 if ($startOfScript === false) { 118 122 return $svgContent; 119 123 } 120 121 //Remove CDATA, since Wordpress does not allow it inside the content122 $svgContent = str_replace('<![CDATA[', '', $svgContent);123 $svgContent = str_replace(']]>', '', $svgContent);124 124 125 125 //add a space after the < char if it is followed by a letter -
svgator/trunk/readme.txt
r2425456 r2427198 1 === SVGator - Add Animated SVG Easily===1 === SVGator === 2 2 3 3 Contributors: alucaci, dzsamper … … 6 6 Requires at least: 5.0 7 7 Tested up to: 5.5.3 8 Stable tag: 1.0. 18 Stable tag: 1.0.2 9 9 10 Connect your SVGator account to easily import your animated SVG projects to your blog 10 The easiest way to add SVG animations to your website right from your SVGator account. 11 11 12 12 == Description == … … 75 75 == Changelog == 76 76 77 = 1.0.2 = 78 * Ability to add a project directly to a post via block editor 79 77 80 = 1.0.1 = 78 81 * Bugs reported by users fixed … … 88 91 == Upgrade Notice == 89 92 90 For full functionality update to version 1.0. 193 For full functionality update to version 1.0.2 91 94 92 95 == Disclosure == -
svgator/trunk/svgator.php
r2425456 r2427198 1 1 <?php 2 2 /** 3 * Plugin Name: SVGator - Add Animated SVG Easily3 * Plugin Name: SVGator 4 4 * Plugin URI: https://www.svgator.com/help/getting-started/how-to-add-svg-to-wordpress 5 5 * Description: Import your animated SVGs from SVGator.com 6 * Version: 1.0. 16 * Version: 1.0.2 7 7 * Author: SVGator 8 8 * Author URI: https://www.svgator.com … … 34 34 } 35 35 36 define('WP_SVGATOR_VERSION', '1.0. 1');36 define('WP_SVGATOR_VERSION', '1.0.2'); 37 37 38 38 require plugin_dir_path(__FILE__) . 'includes/autoload.php'; -
svgator/trunk/wp-svgator-block/css/style.css
r2422334 r2427198 28 28 } 29 29 30 .svgator-popup-projects .svgator-popup-inner.svgator-hidden { 31 display: none; 32 } 33 30 34 .svgator-popup-projects .svgator-popup-inner.svgator-loading { 31 35 background-color: rgba(0, 0, 0, .1); … … 35 39 } 36 40 41 42 .svgator-popup-projects .svgator-popup-inner .svgator-no-project { 43 color: #4c4c4c; 44 font-size: 24px; 45 font-weight: 300; 46 line-height: normal; 47 text-align: center; 48 padding-top: 230px; 49 } 50 51 /** 52 Header of projects 53 */ 54 #svgator-header { 55 align-items: center; 56 display: flex; 57 line-height: 36px; 58 padding: 0 8px; 59 } 60 61 #svgator-header > h1 { 62 margin-right: 20px; 63 padding: 0; 64 } 65 66 #svgator-header > form input { 67 background-image: url("../imgs/magnifier.svg"); 68 background-repeat: no-repeat; 69 background-position: 10px center; 70 border-color: #d3d6d9; 71 border-radius: 4px; 72 height: 36px; 73 line-height: 36px; 74 padding-left: 37px; 75 width: 416px; 76 } 77 78 /** 79 Header of projects 80 */ 37 81 .svgator-popup-projects .svgator-popup-inner > ul > li { 38 82 background-color: #fff; 39 83 border: 1px solid rgba(0, 0, 0, .12); 40 84 border-radius: 4px; 41 display: inline-block;85 display: none; 42 86 margin: 8px; 43 87 overflow: hidden; 44 88 position: relative; 45 89 vertical-align: top; 46 width: 256px; 90 width: calc(16.66% - 16px); 91 } 92 93 .svgator-popup-projects .svgator-popup-inner > ul > li.svgator-on-page.svgator-on-filter { 94 display: inline-block; 47 95 } 48 96 … … 77 125 word-break: break-all; 78 126 } 127 128 /** 129 Pagination 130 */ 131 #svgator-projects-pagination ul { 132 display: inline-flex; 133 justify-content: center; 134 width: 100%; 135 } 136 137 #svgator-projects-pagination li { 138 background-color: #fff; 139 border-radius: 4px; 140 box-shadow: 0 3px 1px -2px rgba(0, 0, 0, .2), 141 0 2px 2px 0 rgba(0, 0, 0, .14), 142 0 1px 5px 0 rgba(0, 0, 0, .12); 143 color: rgba(0, 0, 0, .87); 144 cursor: pointer; 145 font-size: 16px; 146 height: 34px; 147 line-height: 34px; 148 margin: 5px; 149 min-width: 34px; 150 padding: 0 5px; 151 text-align: center; 152 transition: .3s cubic-bezier(0, 0, .2, 1); 153 } 154 155 #svgator-projects-pagination li.active { 156 background-color: #1976d2; 157 box-shadow: 0 2px 4px -1px rgba(0, 0, 0, .2), 158 0 4px 5px 0 rgba(0, 0, 0, .14), 159 0 1px 10px 0 rgba(0, 0, 0, .12); 160 color: #fff; 161 } -
svgator/trunk/wp-svgator-block/js/SVGator_BlockProjects.js
r2422334 r2427198 33 33 type: 'string', 34 34 source: 'html', 35 selector: ' figcaption',35 selector: 'div.wp-block-wp-svgator-insert-svg', 36 36 } 37 37 }, 38 38 edit: function(props) { 39 let placeholder = slf.createPlaceholder(props );39 let placeholder = slf.createPlaceholder(props, 'Please select a SVG.'); 40 40 if (props.isSelected) { 41 slf.popup.showPopup(placeholder, props); 41 if (!props.attributes.htmlContent) { 42 slf.popup.showPopup(placeholder, props); 43 } 42 44 } 43 45 return placeholder; … … 50 52 } 51 53 52 createPlaceholder(props ) {54 createPlaceholder(props, placeholderText = false) { 53 55 if (props.attributes.htmlContent) { 54 //this.$('.svgator-placeholder').remove();55 56 return this.wp.element.createElement( 56 57 'div', 57 58 { 59 className: 'wp-svgator-image', 58 60 dangerouslySetInnerHTML: { 59 61 __html: props.attributes.htmlContent, … … 66 68 'div', 67 69 { 68 className: ' svgator-placeholder',70 className: 'wp-svgator-image', 69 71 }, 70 'Please select a SVG.'72 placeholderText 71 73 ); 74 72 75 } 73 76 … … 121 124 } 122 125 123 edit(params) {124 let pr = svgator_bp.loadProjects();125 if (!pr) {126 return false;127 }128 129 pr.then(function(data){130 if (!data || !data.success) {131 return false;132 }133 }).catch(function(err){134 console.log(err);135 });136 137 return this.createPlaceholder();138 }139 140 save() {141 return null;142 }143 144 126 loadProjects() { 145 127 return this.makeRequest({ -
svgator/trunk/wp-svgator-block/js/SVGator_BlockProjects_Popup.js
r2422334 r2427198 1 1 export default class SVGator_BlockProjects_Popup { 2 projectsPerPage = 18; 3 2 4 constructor(wp, $) { 3 5 this.wp = wp; … … 15 17 let $innerDiv = this.$('<div>') 16 18 .addClass('svgator-popup-inner') 19 .addClass('svgator-hidden') 17 20 .addClass('svgator-loading'); 21 22 let $header = this.getPopupHeader(); 23 24 let $paginator = this.$('<div>') 25 .attr('id', 'svgator-projects-pagination'); 18 26 19 27 let $ul = this.$('<ul>'); … … 32 40 data.response.forEach(function(project){ 33 41 $ul.append(slf.buildProjectLi(project)); 34 $innerDiv.removeClass('svgator-loading');35 42 }); 43 44 $innerDiv.removeClass('svgator-loading'); 45 $innerDiv.removeClass('svgator-hidden'); 46 47 slf.filterProjects(slf.$('#svgator-header [type="search"]').val()); 36 48 }).catch(function(err){ 37 49 console.log(err); … … 39 51 }); 40 52 53 $innerDiv.append($header); 41 54 $innerDiv.append($ul); 55 $innerDiv.append($paginator); 42 56 $outerDiv.append($innerDiv); 43 57 this.$('body').append($outerDiv); 44 58 45 59 this.setupPopupClose($outerDiv); 60 } 61 62 getPopupHeader() { 63 let slf = this; 64 65 let $header = this.$('<div>') 66 .attr('id', 'svgator-header'); 67 68 let $h1 = this.$('<h1>') 69 .text('SVGator'); 70 71 let $filter = this.$('<form>'); 72 let $input = this.$('<input>') 73 .attr('type', 'search') 74 .attr('placeholder', 'Search project...') 75 .on('keyup search', function(e) { 76 slf.filterProjects(e.target.value); 77 }); 78 79 $filter.append($input); 80 81 $header.append($h1); 82 $header.append($filter); 83 return $header; 84 } 85 86 filterProjects(search) { 87 let slf = this; 88 search = slf.$.trim(search).toLowerCase(); 89 slf.$('.svgator-popup-inner .svgator-no-project').remove(); 90 91 let $lis = slf.$('.svgator-popup-inner > ul li'); 92 if (!search) { 93 $lis.addClass('svgator-on-filter'); 94 slf.paginateProjects(); 95 return; 96 } 97 98 $lis.removeClass('svgator-on-filter'); 99 100 $lis.each(function(idx, li) { 101 let $li = slf.$(li); 102 let liText = $li.find('.svgator-title-container').text().toLowerCase(); 103 104 if (liText.indexOf(search) >= 0) { 105 $li.addClass('svgator-on-filter'); 106 } 107 }); 108 109 if ($lis.filter('.svgator-on-filter').length === 0) { 110 let $noProjects = slf.$('<div>') 111 .addClass('svgator-no-project') 112 .text('No project found'); 113 114 slf.$('.svgator-popup-inner').append($noProjects); 115 } 116 117 slf.paginateProjects(); 46 118 } 47 119 … … 72 144 updatePlaceholder(project) { 73 145 let slf = this; 74 this.$('.svgator-popup-inner > ul').remove();146 this.$('.svgator-popup-inner > *').remove(); 75 147 this.$('.svgator-popup-inner').addClass('svgator-loading'); 76 148 … … 136 208 137 209 return $li; 210 } 211 212 paginateProjects() { 213 let $projects = this.$('.svgator-popup-inner li'); 214 $projects.removeClass('svgator-on-page'); 215 216 $projects = $projects.filter('.svgator-on-filter'); 217 218 let $paginationContainer = this.$('#svgator-projects-pagination'); 219 $paginationContainer.empty(); 220 221 let $ul = this.$('<ul>'); 222 223 for (let i = 0; i < $projects.length; i++) { 224 let page = parseInt(i / this.projectsPerPage) + 1; 225 this.$($projects[i]).attr('data-page', page); 226 227 if (!$ul.find('[data-page="' + page + '"]').length) { 228 let $li = this.$('<li>') 229 .attr('data-page', page) 230 .text(page); 231 232 $li.on('click', function() { 233 $projects.removeClass('svgator-on-page'); 234 $projects.filter('[data-page="' + page + '"]').addClass('svgator-on-page'); 235 $li.siblings().removeClass('active'); 236 $li.addClass('active'); 237 }); 238 239 $ul.append($li); 240 } 241 } 242 243 $paginationContainer.append($ul); 244 245 $ul.find('> li').first().click(); 138 246 } 139 247
Note: See TracChangeset
for help on using the changeset viewer.