Changeset 3040959
- Timestamp:
- 02/26/2024 02:43:25 AM (2 years ago)
- Location:
- bibleget-io
- Files:
-
- 2 added
- 10 edited
- 1 copied
-
tags/8.3 (copied) (copied from bibleget-io/trunk)
-
tags/8.3/bibleget-io.php (modified) (5 diffs)
-
tags/8.3/block.json (added)
-
tags/8.3/includes/BibleGetSettingsPage.php (modified) (15 diffs)
-
tags/8.3/includes/custom_controls.php (modified) (1 diff)
-
tags/8.3/js/admin.js (modified) (9 diffs)
-
tags/8.3/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/bibleget-io.php (modified) (5 diffs)
-
trunk/block.json (added)
-
trunk/includes/BibleGetSettingsPage.php (modified) (15 diffs)
-
trunk/includes/custom_controls.php (modified) (1 diff)
-
trunk/js/admin.js (modified) (9 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bibleget-io/tags/8.3/bibleget-io.php
r3040906 r3040959 4 4 * Plugin URI: https://www.bibleget.io/ 5 5 * Description: Easily insert Bible quotes from a choice of Bible versions into your articles or pages with the "Bible quote" block or with the shortcode [bibleget]. 6 * Version: 8. 26 * Version: 8.3 7 7 * Requires at least: 5.6 8 8 * Requires PHP: 7.4 … … 31 31 32 32 33 define("BIBLEGETPLUGINVERSION", "v8_ 2");33 define("BIBLEGETPLUGINVERSION", "v8_3"); 34 34 35 35 if (!defined('ABSPATH')) { … … 144 144 } 145 145 */ 146 if (get_filesystem_method() === 'direct') { 147 $gfontsDir = str_replace('\\','/', wp_upload_dir()["basedir"] ) . "/gfonts_preview/"; 148 $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, array()); 149 /* initialize the API */ 150 if (WP_Filesystem($creds)) { 151 global $wp_filesystem; 152 if ($wp_filesystem->is_dir($gfontsDir)) { 153 $wp_filesystem->rmdir($gfontsDir,true); 154 } 155 } 156 } 146 157 } 147 158 … … 171 182 */ 172 183 function bibleget_set_script_translations() { 173 wp_set_script_translations('bibleget-gutenberg-block', 'bibleget-io'); 174 } 175 add_action('init', 'bibleget_set_script_translations'); 184 $script_handle = generate_block_asset_handle( 'bibleget/bible-quote', 'editorScript' ); 185 wp_set_script_translations($script_handle, 'bibleget-io'); 186 //wp_set_script_translations( $script_handle, 'bibleget-io', plugin_dir_path( __FILE__ ) . 'languages' ); 187 } 188 //add_action('init', 'bibleget_set_script_translations'); 189 add_action( 'enqueue_block_editor_assets', 'bibleget_set_script_translations' ); 176 190 177 191 … … 664 678 } 665 679 } 666 if( file_exists( plugin_dir_path( __FILE__ ) . 'css/gfonts_preview/gfonts_preview.css' ) ){667 wp_enqueue_style( 'bibleget-fontselect-preview',668 plugins_url ('css/gfonts_preview/gfonts_preview.css', __FILE__ )669 );680 $gfontsPreviewCSS = str_replace('\\','/', wp_upload_dir()["basedir"] ) . "/gfonts_preview/css/gfonts_preview.css"; 681 $gfontsPreviewURL = wp_upload_dir()["baseurl"] . "/gfonts_preview/css/gfonts_preview.css"; 682 if( file_exists( $gfontsPreviewCSS ) ){ 683 wp_enqueue_style( 'bibleget-fontselect-preview', $gfontsPreviewURL ); 670 684 } 671 685 } -
bibleget-io/tags/8.3/includes/BibleGetSettingsPage.php
r3040715 r3040959 182 182 $lang = $this->locale; 183 183 } 184 if (strlen($lang) == 2) {184 if (strlen($lang) === 2) { 185 185 //we have a two-letter ISO code, we need to get the full language name in English 186 186 if (extension_loaded('intl') === true) { … … 265 265 public function admin_print_styles($hook) 266 266 { 267 if ($hook == 'settings_page_bibleget-settings-admin') {267 if ($hook === 'settings_page_bibleget-settings-admin') { 268 268 wp_enqueue_style('admin-css', plugins_url('../css/admin.css', __FILE__)); 269 269 } … … 289 289 wp_enqueue_script('admin-js'); 290 290 291 if ($this->gfontsAPIkeyCheckResult == "SUCCESS") {291 if ($this->gfontsAPIkeyCheckResult === "SUCCESS") { 292 292 //We only want the transient to be set from the bibleget settings page, so we wait until now 293 293 // instead of doing it in the gfontsAPIkeyCheck (which is called on any admin interface) 294 294 set_transient(md5($this->options['googlefontsapi_key']), $this->gfontsAPIkeyCheckResult, 90 * 24 * HOUR_IN_SECONDS); // 90 giorni 295 295 296 $plugin_path = "";297 296 // bibleGetWriteLog("about to initialize creation of admin page..."); 298 297 if (get_filesystem_method() === 'direct') { 299 $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, array()); 298 $gfontsDir = str_replace('\\','/', wp_upload_dir()["basedir"] ) . "/gfonts_preview/"; 299 $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, array()); 300 300 /* initialize the API */ 301 301 if (WP_Filesystem($creds)) { 302 302 global $wp_filesystem; 303 $plugin_path = str_replace('\\','/', plugin_dir_path( __FILE__ ) ); 304 if (!$wp_filesystem->is_dir($plugin_path . '../gfonts_preview/')) { 303 if (!$wp_filesystem->is_dir($gfontsDir)) { 305 304 /* directory didn't exist, so let's create it */ 306 if ($wp_filesystem->mkdir($ plugin_path . '../gfonts_preview/') === false) {305 if ($wp_filesystem->mkdir($gfontsDir) === false) { 307 306 $this->gfontsAPI_errors[] = "Could not create directory gfonts_preview"; 307 } else { 308 //let's make sure the necessary subfolders are also created 309 if(!$wp_filesystem->is_dir($gfontsDir . "ttf/")) { 310 if( $wp_filesystem->mkdir($gfontsDir . "ttf/") === false ) { 311 $this->gfontsAPI_errors[] = "Could not create directory gfonts_preview/ttf"; 312 } 313 } 314 if(!$wp_filesystem->is_dir($gfontsDir . "css/")) { 315 if( $wp_filesystem->mkdir($gfontsDir . "css/") === false ) { 316 $this->gfontsAPI_errors[] = "Could not create directory gfonts_preview/css"; 317 } 318 } 308 319 } 309 320 } 310 if (!$wp_filesystem->is_dir($plugin_path . '../css/gfonts_preview/')) {311 /* directory didn't exist, so let's create it */312 if ($wp_filesystem->mkdir($plugin_path . '../css/gfonts_preview/') === false) {313 $this->gfontsAPI_errors[] = "Could not create directory css/gfonts_preview";314 }315 }316 321 317 322 //let's also cache the results from the Google Fonts API in a local file so we don't have to keep calling 318 323 if ($wp_filesystem->put_contents( 319 $ plugin_path . '../gfonts_preview/gfontsWeblist.json',324 $gfontsDir . 'gfontsWeblist.json', 320 325 json_encode($this->gfonts_weblist), 321 326 FS_CHMOD_FILE // predefined mode settings for WP files … … 330 335 } 331 336 if(count($this->gfontsAPI_errors) > 0 ){ 332 add_action( 'admin_notices', function(){ printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( 'notice notice-error' ), esc_html( __( 'Impossible to write data to the BibleGet plugin directory, please check permissions!', 'bibleget-io' ) ) ); } ); 337 add_action( 338 'admin_notices', 339 function(){ 340 printf( 341 '<div class="%1$s"><p>%2$s</p></div>', 342 esc_attr( 'notice notice-error' ), 343 esc_html( 344 __( 'Impossible to write data to the BibleGet plugin directory, please check permissions!', 'bibleget-io' ) 345 . "\n" . implode("\n",$this->gfontsAPI_errors) 346 ) 347 ); 348 } 349 ); 333 350 } 334 351 wp_enqueue_script('jquery-ui-progressbar'); … … 571 588 echo '<span style="color:DarkViolet;font-weight:bold;margin-left:12px;">' . __("CURL ERROR WHEN SENDING REQUEST", "bibleget-io") . '</span><br />'; 572 589 foreach ($this->gfontsAPI_errors as $er) { 573 if ($er == 403) {590 if ($er === 403) { 574 591 echo '<br /><i style="color:DarkViolet;margin-left:12px;">'; 575 592 echo __("This server's IP address has not been given access to the Google Fonts API using this key.", "bibleget-io"); … … 659 676 $response = curl_exec($ch); 660 677 $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); 661 if ($response && !curl_errno($ch) && $status == 200) {678 if ($response && !curl_errno($ch) && $status === 200) { 662 679 //let's see what was returned, and if it's what we're looking for 663 680 $json_response = json_decode($response); 664 681 if ($json_response !== null && json_last_error() === JSON_ERROR_NONE) { 665 682 //So far so good, let's keep these results for other functions to access 666 if (property_exists($json_response, "kind") && $json_response->kind == "webfonts#webfontList" && property_exists($json_response, "items")) {683 if (property_exists($json_response, "kind") && $json_response->kind === "webfonts#webfontList" && property_exists($json_response, "items")) { 667 684 $this->gfonts_weblist = $json_response; 668 685 $result = "SUCCESS"; … … 680 697 } 681 698 if ($status != 200) { 682 if ($status == 403) {699 if ($status === 403) { 683 700 $this->gfontsAPI_errors[] = $status; 684 701 } else { … … 723 740 $familyfilename = ""; 724 741 $errorinfo = []; 725 $gfontsDir = str_replace('\\','/', plugin_dir_path( __FILE__ ) ) . "../gfonts_preview/"; 742 $gfontsDir = str_replace('\\','/', wp_upload_dir()["basedir"] ) . "/gfonts_preview/"; 743 $gfontsWeblistFile = $gfontsDir . "gfontsWeblist.json"; 726 744 $gfontsWeblist = new stdClass(); 727 745 $returnInfo = new stdClass(); 728 746 729 if (file_exists($gfonts Dir . "gfontsWeblist.json")) {730 $gfontsWeblistFile = file_get_contents($gfontsDir . "gfontsWeblist.json");731 $gfontsWeblist = json_decode($gfontsWeblistFile );747 if (file_exists($gfontsWeblistFile)) { 748 $gfontsWeblistFileContents = file_get_contents($gfontsWeblistFile); 749 $gfontsWeblist = json_decode($gfontsWeblistFileContents); 732 750 } 733 751 if ( 734 isset($_POST["gfontsCount"], $_POST["batchLimit"], $_POST["startIdx"], $_POST["lastBatchLimit"], $_POST["numRuns"], $_POST["currentRun"]) 735 && property_exists($gfontsWeblist, "items")) { 752 isset( 753 $_POST["gfontsCount"], 754 $_POST["batchLimit"], 755 $_POST["startIdx"], 756 $_POST["lastBatchLimit"], 757 $_POST["numRuns"], 758 $_POST["currentRun"] 759 ) && property_exists($gfontsWeblist, "items")) 760 { 736 761 //$gfontsCount = intval($_POST["gfontsCount"]); 737 762 $batchLimit = intval($_POST["batchLimit"]); … … 748 773 } 749 774 750 $plugin_path = "";751 775 if (get_filesystem_method() === 'direct') { 752 776 $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, array()); … … 754 778 if (WP_Filesystem($creds)) { 755 779 global $wp_filesystem; 756 $plugin_path = str_replace('\\','/', plugin_dir_path( __FILE__ ) );757 780 758 781 foreach ($gfontsWeblist->items as $idx => $googlefont) { … … 764 787 $fnttype = 'ttf'; //'woff', 'woff2', 'ttf' 765 788 766 if (!file_exists($gfontsDir . " {$familyfilename}.{$fnttype}")) { //$idx < $idxlimit &&789 if (!file_exists($gfontsDir . "ttf/{$familyfilename}.{$fnttype}")) { //$idx < $idxlimit && 767 790 $ch2 = curl_init("https://fonts.googleapis.com/css2?family={$familyurlname}&text={$familyfilename}"); 768 791 curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, TRUE); … … 780 803 $status2 = (int) curl_getinfo($ch2, CURLINFO_HTTP_CODE); 781 804 $returnInfo->httpStatus2 = $status2; 782 if ($response2 && !curl_errno($ch2) && $status2 == 200) {783 if (preg_match('/url\((.*?)\)/', $response2, $match) == 1) {805 if ($response2 && !curl_errno($ch2) && $status2 === 200) { 806 if (preg_match('/url\((.*?)\)/', $response2, $match) === 1) { 784 807 $thisfonturl = $match[1]; 785 808 $errorinfo[] = "font retrieval url for {$thisfamily} = {$thisfonturl}"; 786 809 787 // $ch3_headers = [];810 //$ch3_headers = []; 788 811 $ch3 = curl_init($thisfonturl); 789 812 curl_setopt($ch3, CURLOPT_SSL_VERIFYPEER, TRUE); … … 802 825 } 803 826 $response3 = curl_exec($ch3); 804 // $errorinfo[] = print_r($ch3_headers,TRUE);827 //$errorinfo[] = print_r($ch3_headers,TRUE); 805 828 $status3 = (int) curl_getinfo($ch3, CURLINFO_HTTP_CODE); 806 829 $returnInfo->httpStatus3 = $status3; 807 if ($response3 && !curl_errno($ch3) && $status3 == 200) {830 if ($response3 && !curl_errno($ch3) && $status3 === 200) { 808 831 if ($wp_filesystem) { 809 //if(!file_exists($ plugin_path . "../gfonts_preview/{$familyfilename}.{$fnttype}") ){832 //if(!file_exists($gfontsDir . "ttf/{$familyfilename}.{$fnttype}") ){ 810 833 if (!$wp_filesystem->put_contents( 811 $gfontsDir . " {$familyfilename}.{$fnttype}",834 $gfontsDir . "ttf/{$familyfilename}.{$fnttype}", 812 835 $response3, 813 836 FS_CHMOD_FILE 814 837 )) { 815 $errorinfo[] = "Cannot write file " . $ plugin_path . "../gfonts_preview/{$familyfilename}.{$fnttype} with wordpress filesystem api, sorry";838 $errorinfo[] = "Cannot write file " . $gfontsDir . "ttf/{$familyfilename}.{$fnttype} with wordpress filesystem api, sorry"; 816 839 } else { 817 $gfont_stylesheet = preg_replace('/url\((.*?)\)/', 'url(' . esc_url(plugins_url("../gfonts_preview/{$familyfilename}.{$fnttype}", __FILE__)) . ')', $response2); 818 if (!file_exists($plugin_path . "../css/gfonts_preview/{$familyfilename}.css")) { 840 $uploadURL = wp_upload_dir()["baseurl"]; 841 $gfont_stylesheet = preg_replace('/url\((.*?)\)/', 'url(' . esc_url("{$uploadURL}/gfonts_preview/ttf/{$familyfilename}.{$fnttype}") . ')', $response2); 842 if (!file_exists($gfontsDir . "css/{$familyfilename}.css")) { 819 843 if (!$wp_filesystem->put_contents( 820 $ plugin_path . "../css/gfonts_preview/{$familyfilename}.css",844 $gfontsDir . "css/{$familyfilename}.css", 821 845 $gfont_stylesheet, 822 846 FS_CHMOD_FILE 823 847 )) { 824 $errorinfo[] = "Cannot write file " . $ plugin_path . "../css/gfonts_preview/{$familyfilename}.css with wordpress filesystem api, sorry";848 $errorinfo[] = "Cannot write file " . $gfontsDir . "css/{$familyfilename}.css with wordpress filesystem api, sorry"; 825 849 } 826 850 } … … 863 887 864 888 865 // echo print_r($errorinfo);889 //echo print_r($errorinfo); 866 890 if (($startIdx + ($batchLimit - 1)) < ($totalFonts - 1)) { 867 891 $returnInfo->state = "RUN_PROCESSED"; … … 871 895 872 896 //LAST STEP IS TO MINIFY ALL OF THE CSS FILES INTO ONE SINGLE FILE 873 $cssdirectory = str_replace('\\','/', plugin_dir_path( __FILE__ ) ) . "../css/gfonts_preview";897 $cssdirectory = $gfontsDir . "css"; 874 898 $cssfiles = array_diff(scandir($cssdirectory), array('..', '.', 'gfonts_preview.css')); 875 876 899 $minifier = new MatthiasMullie\Minify\CSS($cssdirectory . "/" . (array_shift($cssfiles))); 877 900 while (count($cssfiles) > 0) { -
bibleget-io/tags/8.3/includes/custom_controls.php
r3037594 r3040959 90 90 ); 91 91 92 if( file_exists( plugin_dir_path( __FILE__ ) . '../css/gfonts_preview/gfonts_preview.css' ) ){93 wp_enqueue_style( 'bibleget-fontselect-preview',94 plugins_url ('../css/gfonts_preview/gfonts_preview.css', __FILE__ )95 );92 $gfontsDir = str_replace('\\','/', wp_upload_dir()["basedir"] ) . "/gfonts_preview/"; 93 $gfontsPreviewCSS = esc_url( wp_upload_dir()["baseurl"] . '/gfonts_preview/css/gfonts_preview.css' ); 94 if( file_exists( $gfontsDir . 'css/gfonts_preview.css' ) ){ 95 wp_enqueue_style( 'bibleget-fontselect-preview', $gfontsPreviewCSS ); 96 96 } 97 97 else{ -
bibleget-io/tags/8.3/js/admin.js
r3040715 r3040959 64 64 }, 65 65 success: (returndata) => { 66 if (returndata == "datarefreshed") {66 if (returndata === "datarefreshed") { 67 67 jQuery("#bibleget-settings-notification") 68 68 .append( … … 73 73 let interval1 = setInterval(() => { 74 74 jQuery("#bibleget-countdown").text( 75 --seconds + (seconds == 1 ? " sec..." : " secs...")75 --seconds + (seconds === 1 ? " sec..." : " secs...") 76 76 ); 77 77 }, 1000); … … 114 114 }, 115 115 success: (returndata) => { 116 if (returndata == "cacheflushed") {116 if (returndata === "cacheflushed") { 117 117 jQuery("#bibleget-settings-notification") 118 118 .append("Bible quotes cache emptied successfully") … … 146 146 gfontsBatch.job.gfontsPreviewJob === true && 147 147 gfontsBatch.job.hasOwnProperty("gfontsWeblist") && 148 typeof gfontsBatch.job.gfontsWeblist == "object" &&148 typeof gfontsBatch.job.gfontsWeblist === "object" && 149 149 gfontsBatch.job.gfontsWeblist.hasOwnProperty("items") 150 150 ) { … … 160 160 $("<div>", { 161 161 html: 162 "!!! Impossible to write data to the BibleGet plugin directory, please check permissions! ",162 "!!! Impossible to write data to the BibleGet plugin directory, please check permissions!<br>" + wpFsErrors.join('<br>'), 163 163 style: 164 164 "color: white; background-color: red; padding: 3px 9px; display: inline-block; font-weight: bold; font-family: sans-serif;", … … 186 186 //console.log('batchLimit = '+batchLimit); 187 187 } 188 //We actually need to run one more time than the batchlimit, in order for the minify stage to take place 189 numRuns++; 188 190 189 191 //$gfontsBatchRunProgressbarOverlay, $gfontsBatchRunProgressbarWrapper, and $gfontsBatchRunProgressbar are global variables so don't use "var" here … … 324 326 if ( 325 327 (returndataJSON.hasOwnProperty("httpStatus2") && 326 returndataJSON.httpStatus2 == 504) ||328 returndataJSON.httpStatus2 === 504) || 327 329 (returndataJSON.hasOwnProperty("httpStatus3") && 328 returndataJSON.httpStatus3 == 504)330 returndataJSON.httpStatus3 === 504) 329 331 ) { 330 332 //there was a timeout at some point during the communication with the Google Fonts server … … 368 370 $gfontsBatchRunProgressbar.progressbar("value", 100); 369 371 370 // if (thisRun == postdata.numRuns) {372 // if (thisRun === postdata.numRuns) { 371 373 // console.log("gfontsBatchRun has finished the job!"); 372 374 // } else { … … 461 463 //console.log('we should have an nonce for this action: '+gfontsBatch.gfontsRefreshNonce); 462 464 if ( 463 typeof gfontsBatch != "undefined" &&464 typeof gfontsBatch == "object" &&465 typeof gfontsBatch !== "undefined" && 466 typeof gfontsBatch === "object" && 465 467 gfontsBatch.hasOwnProperty("job") && 466 typeof gfontsBatch.job == "object" &&468 typeof gfontsBatch.job === "object" && 467 469 gfontsBatch.job.hasOwnProperty("gfontsRefreshNonce") && 468 gfontsBatch.job.gfontsRefreshNonce != "" &&470 gfontsBatch.job.gfontsRefreshNonce !== "" && 469 471 gfontsBatch.job.hasOwnProperty("gfontsApiKey") && 470 gfontsBatch.job.gfontsApiKey != ""472 gfontsBatch.job.gfontsApiKey !== "" 471 473 ) { 472 474 const postProps = { -
bibleget-io/tags/8.3/vendor/composer/installed.php
r3040906 r3040959 2 2 'root' => array( 3 3 'name' => 'johnrdorazio/bibleget-wordpress', 4 'pretty_version' => '8. 2',5 'version' => '8. 2.0.0',6 'reference' => ' 442a7919a8a39ee149b5136f453972f664554573',4 'pretty_version' => '8.3', 5 'version' => '8.3.0.0', 6 'reference' => 'c1c96795fb7f3ab11fb8a4e3234130945b8458b6', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'johnrdorazio/bibleget-wordpress' => array( 14 'pretty_version' => '8. 2',15 'version' => '8. 2.0.0',16 'reference' => ' 442a7919a8a39ee149b5136f453972f664554573',14 'pretty_version' => '8.3', 15 'version' => '8.3.0.0', 16 'reference' => 'c1c96795fb7f3ab11fb8a4e3234130945b8458b6', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
bibleget-io/trunk/bibleget-io.php
r3040906 r3040959 4 4 * Plugin URI: https://www.bibleget.io/ 5 5 * Description: Easily insert Bible quotes from a choice of Bible versions into your articles or pages with the "Bible quote" block or with the shortcode [bibleget]. 6 * Version: 8. 26 * Version: 8.3 7 7 * Requires at least: 5.6 8 8 * Requires PHP: 7.4 … … 31 31 32 32 33 define("BIBLEGETPLUGINVERSION", "v8_ 2");33 define("BIBLEGETPLUGINVERSION", "v8_3"); 34 34 35 35 if (!defined('ABSPATH')) { … … 144 144 } 145 145 */ 146 if (get_filesystem_method() === 'direct') { 147 $gfontsDir = str_replace('\\','/', wp_upload_dir()["basedir"] ) . "/gfonts_preview/"; 148 $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, array()); 149 /* initialize the API */ 150 if (WP_Filesystem($creds)) { 151 global $wp_filesystem; 152 if ($wp_filesystem->is_dir($gfontsDir)) { 153 $wp_filesystem->rmdir($gfontsDir,true); 154 } 155 } 156 } 146 157 } 147 158 … … 171 182 */ 172 183 function bibleget_set_script_translations() { 173 wp_set_script_translations('bibleget-gutenberg-block', 'bibleget-io'); 174 } 175 add_action('init', 'bibleget_set_script_translations'); 184 $script_handle = generate_block_asset_handle( 'bibleget/bible-quote', 'editorScript' ); 185 wp_set_script_translations($script_handle, 'bibleget-io'); 186 //wp_set_script_translations( $script_handle, 'bibleget-io', plugin_dir_path( __FILE__ ) . 'languages' ); 187 } 188 //add_action('init', 'bibleget_set_script_translations'); 189 add_action( 'enqueue_block_editor_assets', 'bibleget_set_script_translations' ); 176 190 177 191 … … 664 678 } 665 679 } 666 if( file_exists( plugin_dir_path( __FILE__ ) . 'css/gfonts_preview/gfonts_preview.css' ) ){667 wp_enqueue_style( 'bibleget-fontselect-preview',668 plugins_url ('css/gfonts_preview/gfonts_preview.css', __FILE__ )669 );680 $gfontsPreviewCSS = str_replace('\\','/', wp_upload_dir()["basedir"] ) . "/gfonts_preview/css/gfonts_preview.css"; 681 $gfontsPreviewURL = wp_upload_dir()["baseurl"] . "/gfonts_preview/css/gfonts_preview.css"; 682 if( file_exists( $gfontsPreviewCSS ) ){ 683 wp_enqueue_style( 'bibleget-fontselect-preview', $gfontsPreviewURL ); 670 684 } 671 685 } -
bibleget-io/trunk/includes/BibleGetSettingsPage.php
r3040715 r3040959 182 182 $lang = $this->locale; 183 183 } 184 if (strlen($lang) == 2) {184 if (strlen($lang) === 2) { 185 185 //we have a two-letter ISO code, we need to get the full language name in English 186 186 if (extension_loaded('intl') === true) { … … 265 265 public function admin_print_styles($hook) 266 266 { 267 if ($hook == 'settings_page_bibleget-settings-admin') {267 if ($hook === 'settings_page_bibleget-settings-admin') { 268 268 wp_enqueue_style('admin-css', plugins_url('../css/admin.css', __FILE__)); 269 269 } … … 289 289 wp_enqueue_script('admin-js'); 290 290 291 if ($this->gfontsAPIkeyCheckResult == "SUCCESS") {291 if ($this->gfontsAPIkeyCheckResult === "SUCCESS") { 292 292 //We only want the transient to be set from the bibleget settings page, so we wait until now 293 293 // instead of doing it in the gfontsAPIkeyCheck (which is called on any admin interface) 294 294 set_transient(md5($this->options['googlefontsapi_key']), $this->gfontsAPIkeyCheckResult, 90 * 24 * HOUR_IN_SECONDS); // 90 giorni 295 295 296 $plugin_path = "";297 296 // bibleGetWriteLog("about to initialize creation of admin page..."); 298 297 if (get_filesystem_method() === 'direct') { 299 $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, array()); 298 $gfontsDir = str_replace('\\','/', wp_upload_dir()["basedir"] ) . "/gfonts_preview/"; 299 $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, array()); 300 300 /* initialize the API */ 301 301 if (WP_Filesystem($creds)) { 302 302 global $wp_filesystem; 303 $plugin_path = str_replace('\\','/', plugin_dir_path( __FILE__ ) ); 304 if (!$wp_filesystem->is_dir($plugin_path . '../gfonts_preview/')) { 303 if (!$wp_filesystem->is_dir($gfontsDir)) { 305 304 /* directory didn't exist, so let's create it */ 306 if ($wp_filesystem->mkdir($ plugin_path . '../gfonts_preview/') === false) {305 if ($wp_filesystem->mkdir($gfontsDir) === false) { 307 306 $this->gfontsAPI_errors[] = "Could not create directory gfonts_preview"; 307 } else { 308 //let's make sure the necessary subfolders are also created 309 if(!$wp_filesystem->is_dir($gfontsDir . "ttf/")) { 310 if( $wp_filesystem->mkdir($gfontsDir . "ttf/") === false ) { 311 $this->gfontsAPI_errors[] = "Could not create directory gfonts_preview/ttf"; 312 } 313 } 314 if(!$wp_filesystem->is_dir($gfontsDir . "css/")) { 315 if( $wp_filesystem->mkdir($gfontsDir . "css/") === false ) { 316 $this->gfontsAPI_errors[] = "Could not create directory gfonts_preview/css"; 317 } 318 } 308 319 } 309 320 } 310 if (!$wp_filesystem->is_dir($plugin_path . '../css/gfonts_preview/')) {311 /* directory didn't exist, so let's create it */312 if ($wp_filesystem->mkdir($plugin_path . '../css/gfonts_preview/') === false) {313 $this->gfontsAPI_errors[] = "Could not create directory css/gfonts_preview";314 }315 }316 321 317 322 //let's also cache the results from the Google Fonts API in a local file so we don't have to keep calling 318 323 if ($wp_filesystem->put_contents( 319 $ plugin_path . '../gfonts_preview/gfontsWeblist.json',324 $gfontsDir . 'gfontsWeblist.json', 320 325 json_encode($this->gfonts_weblist), 321 326 FS_CHMOD_FILE // predefined mode settings for WP files … … 330 335 } 331 336 if(count($this->gfontsAPI_errors) > 0 ){ 332 add_action( 'admin_notices', function(){ printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( 'notice notice-error' ), esc_html( __( 'Impossible to write data to the BibleGet plugin directory, please check permissions!', 'bibleget-io' ) ) ); } ); 337 add_action( 338 'admin_notices', 339 function(){ 340 printf( 341 '<div class="%1$s"><p>%2$s</p></div>', 342 esc_attr( 'notice notice-error' ), 343 esc_html( 344 __( 'Impossible to write data to the BibleGet plugin directory, please check permissions!', 'bibleget-io' ) 345 . "\n" . implode("\n",$this->gfontsAPI_errors) 346 ) 347 ); 348 } 349 ); 333 350 } 334 351 wp_enqueue_script('jquery-ui-progressbar'); … … 571 588 echo '<span style="color:DarkViolet;font-weight:bold;margin-left:12px;">' . __("CURL ERROR WHEN SENDING REQUEST", "bibleget-io") . '</span><br />'; 572 589 foreach ($this->gfontsAPI_errors as $er) { 573 if ($er == 403) {590 if ($er === 403) { 574 591 echo '<br /><i style="color:DarkViolet;margin-left:12px;">'; 575 592 echo __("This server's IP address has not been given access to the Google Fonts API using this key.", "bibleget-io"); … … 659 676 $response = curl_exec($ch); 660 677 $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); 661 if ($response && !curl_errno($ch) && $status == 200) {678 if ($response && !curl_errno($ch) && $status === 200) { 662 679 //let's see what was returned, and if it's what we're looking for 663 680 $json_response = json_decode($response); 664 681 if ($json_response !== null && json_last_error() === JSON_ERROR_NONE) { 665 682 //So far so good, let's keep these results for other functions to access 666 if (property_exists($json_response, "kind") && $json_response->kind == "webfonts#webfontList" && property_exists($json_response, "items")) {683 if (property_exists($json_response, "kind") && $json_response->kind === "webfonts#webfontList" && property_exists($json_response, "items")) { 667 684 $this->gfonts_weblist = $json_response; 668 685 $result = "SUCCESS"; … … 680 697 } 681 698 if ($status != 200) { 682 if ($status == 403) {699 if ($status === 403) { 683 700 $this->gfontsAPI_errors[] = $status; 684 701 } else { … … 723 740 $familyfilename = ""; 724 741 $errorinfo = []; 725 $gfontsDir = str_replace('\\','/', plugin_dir_path( __FILE__ ) ) . "../gfonts_preview/"; 742 $gfontsDir = str_replace('\\','/', wp_upload_dir()["basedir"] ) . "/gfonts_preview/"; 743 $gfontsWeblistFile = $gfontsDir . "gfontsWeblist.json"; 726 744 $gfontsWeblist = new stdClass(); 727 745 $returnInfo = new stdClass(); 728 746 729 if (file_exists($gfonts Dir . "gfontsWeblist.json")) {730 $gfontsWeblistFile = file_get_contents($gfontsDir . "gfontsWeblist.json");731 $gfontsWeblist = json_decode($gfontsWeblistFile );747 if (file_exists($gfontsWeblistFile)) { 748 $gfontsWeblistFileContents = file_get_contents($gfontsWeblistFile); 749 $gfontsWeblist = json_decode($gfontsWeblistFileContents); 732 750 } 733 751 if ( 734 isset($_POST["gfontsCount"], $_POST["batchLimit"], $_POST["startIdx"], $_POST["lastBatchLimit"], $_POST["numRuns"], $_POST["currentRun"]) 735 && property_exists($gfontsWeblist, "items")) { 752 isset( 753 $_POST["gfontsCount"], 754 $_POST["batchLimit"], 755 $_POST["startIdx"], 756 $_POST["lastBatchLimit"], 757 $_POST["numRuns"], 758 $_POST["currentRun"] 759 ) && property_exists($gfontsWeblist, "items")) 760 { 736 761 //$gfontsCount = intval($_POST["gfontsCount"]); 737 762 $batchLimit = intval($_POST["batchLimit"]); … … 748 773 } 749 774 750 $plugin_path = "";751 775 if (get_filesystem_method() === 'direct') { 752 776 $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, array()); … … 754 778 if (WP_Filesystem($creds)) { 755 779 global $wp_filesystem; 756 $plugin_path = str_replace('\\','/', plugin_dir_path( __FILE__ ) );757 780 758 781 foreach ($gfontsWeblist->items as $idx => $googlefont) { … … 764 787 $fnttype = 'ttf'; //'woff', 'woff2', 'ttf' 765 788 766 if (!file_exists($gfontsDir . " {$familyfilename}.{$fnttype}")) { //$idx < $idxlimit &&789 if (!file_exists($gfontsDir . "ttf/{$familyfilename}.{$fnttype}")) { //$idx < $idxlimit && 767 790 $ch2 = curl_init("https://fonts.googleapis.com/css2?family={$familyurlname}&text={$familyfilename}"); 768 791 curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, TRUE); … … 780 803 $status2 = (int) curl_getinfo($ch2, CURLINFO_HTTP_CODE); 781 804 $returnInfo->httpStatus2 = $status2; 782 if ($response2 && !curl_errno($ch2) && $status2 == 200) {783 if (preg_match('/url\((.*?)\)/', $response2, $match) == 1) {805 if ($response2 && !curl_errno($ch2) && $status2 === 200) { 806 if (preg_match('/url\((.*?)\)/', $response2, $match) === 1) { 784 807 $thisfonturl = $match[1]; 785 808 $errorinfo[] = "font retrieval url for {$thisfamily} = {$thisfonturl}"; 786 809 787 // $ch3_headers = [];810 //$ch3_headers = []; 788 811 $ch3 = curl_init($thisfonturl); 789 812 curl_setopt($ch3, CURLOPT_SSL_VERIFYPEER, TRUE); … … 802 825 } 803 826 $response3 = curl_exec($ch3); 804 // $errorinfo[] = print_r($ch3_headers,TRUE);827 //$errorinfo[] = print_r($ch3_headers,TRUE); 805 828 $status3 = (int) curl_getinfo($ch3, CURLINFO_HTTP_CODE); 806 829 $returnInfo->httpStatus3 = $status3; 807 if ($response3 && !curl_errno($ch3) && $status3 == 200) {830 if ($response3 && !curl_errno($ch3) && $status3 === 200) { 808 831 if ($wp_filesystem) { 809 //if(!file_exists($ plugin_path . "../gfonts_preview/{$familyfilename}.{$fnttype}") ){832 //if(!file_exists($gfontsDir . "ttf/{$familyfilename}.{$fnttype}") ){ 810 833 if (!$wp_filesystem->put_contents( 811 $gfontsDir . " {$familyfilename}.{$fnttype}",834 $gfontsDir . "ttf/{$familyfilename}.{$fnttype}", 812 835 $response3, 813 836 FS_CHMOD_FILE 814 837 )) { 815 $errorinfo[] = "Cannot write file " . $ plugin_path . "../gfonts_preview/{$familyfilename}.{$fnttype} with wordpress filesystem api, sorry";838 $errorinfo[] = "Cannot write file " . $gfontsDir . "ttf/{$familyfilename}.{$fnttype} with wordpress filesystem api, sorry"; 816 839 } else { 817 $gfont_stylesheet = preg_replace('/url\((.*?)\)/', 'url(' . esc_url(plugins_url("../gfonts_preview/{$familyfilename}.{$fnttype}", __FILE__)) . ')', $response2); 818 if (!file_exists($plugin_path . "../css/gfonts_preview/{$familyfilename}.css")) { 840 $uploadURL = wp_upload_dir()["baseurl"]; 841 $gfont_stylesheet = preg_replace('/url\((.*?)\)/', 'url(' . esc_url("{$uploadURL}/gfonts_preview/ttf/{$familyfilename}.{$fnttype}") . ')', $response2); 842 if (!file_exists($gfontsDir . "css/{$familyfilename}.css")) { 819 843 if (!$wp_filesystem->put_contents( 820 $ plugin_path . "../css/gfonts_preview/{$familyfilename}.css",844 $gfontsDir . "css/{$familyfilename}.css", 821 845 $gfont_stylesheet, 822 846 FS_CHMOD_FILE 823 847 )) { 824 $errorinfo[] = "Cannot write file " . $ plugin_path . "../css/gfonts_preview/{$familyfilename}.css with wordpress filesystem api, sorry";848 $errorinfo[] = "Cannot write file " . $gfontsDir . "css/{$familyfilename}.css with wordpress filesystem api, sorry"; 825 849 } 826 850 } … … 863 887 864 888 865 // echo print_r($errorinfo);889 //echo print_r($errorinfo); 866 890 if (($startIdx + ($batchLimit - 1)) < ($totalFonts - 1)) { 867 891 $returnInfo->state = "RUN_PROCESSED"; … … 871 895 872 896 //LAST STEP IS TO MINIFY ALL OF THE CSS FILES INTO ONE SINGLE FILE 873 $cssdirectory = str_replace('\\','/', plugin_dir_path( __FILE__ ) ) . "../css/gfonts_preview";897 $cssdirectory = $gfontsDir . "css"; 874 898 $cssfiles = array_diff(scandir($cssdirectory), array('..', '.', 'gfonts_preview.css')); 875 876 899 $minifier = new MatthiasMullie\Minify\CSS($cssdirectory . "/" . (array_shift($cssfiles))); 877 900 while (count($cssfiles) > 0) { -
bibleget-io/trunk/includes/custom_controls.php
r3037594 r3040959 90 90 ); 91 91 92 if( file_exists( plugin_dir_path( __FILE__ ) . '../css/gfonts_preview/gfonts_preview.css' ) ){93 wp_enqueue_style( 'bibleget-fontselect-preview',94 plugins_url ('../css/gfonts_preview/gfonts_preview.css', __FILE__ )95 );92 $gfontsDir = str_replace('\\','/', wp_upload_dir()["basedir"] ) . "/gfonts_preview/"; 93 $gfontsPreviewCSS = esc_url( wp_upload_dir()["baseurl"] . '/gfonts_preview/css/gfonts_preview.css' ); 94 if( file_exists( $gfontsDir . 'css/gfonts_preview.css' ) ){ 95 wp_enqueue_style( 'bibleget-fontselect-preview', $gfontsPreviewCSS ); 96 96 } 97 97 else{ -
bibleget-io/trunk/js/admin.js
r3040715 r3040959 64 64 }, 65 65 success: (returndata) => { 66 if (returndata == "datarefreshed") {66 if (returndata === "datarefreshed") { 67 67 jQuery("#bibleget-settings-notification") 68 68 .append( … … 73 73 let interval1 = setInterval(() => { 74 74 jQuery("#bibleget-countdown").text( 75 --seconds + (seconds == 1 ? " sec..." : " secs...")75 --seconds + (seconds === 1 ? " sec..." : " secs...") 76 76 ); 77 77 }, 1000); … … 114 114 }, 115 115 success: (returndata) => { 116 if (returndata == "cacheflushed") {116 if (returndata === "cacheflushed") { 117 117 jQuery("#bibleget-settings-notification") 118 118 .append("Bible quotes cache emptied successfully") … … 146 146 gfontsBatch.job.gfontsPreviewJob === true && 147 147 gfontsBatch.job.hasOwnProperty("gfontsWeblist") && 148 typeof gfontsBatch.job.gfontsWeblist == "object" &&148 typeof gfontsBatch.job.gfontsWeblist === "object" && 149 149 gfontsBatch.job.gfontsWeblist.hasOwnProperty("items") 150 150 ) { … … 160 160 $("<div>", { 161 161 html: 162 "!!! Impossible to write data to the BibleGet plugin directory, please check permissions! ",162 "!!! Impossible to write data to the BibleGet plugin directory, please check permissions!<br>" + wpFsErrors.join('<br>'), 163 163 style: 164 164 "color: white; background-color: red; padding: 3px 9px; display: inline-block; font-weight: bold; font-family: sans-serif;", … … 186 186 //console.log('batchLimit = '+batchLimit); 187 187 } 188 //We actually need to run one more time than the batchlimit, in order for the minify stage to take place 189 numRuns++; 188 190 189 191 //$gfontsBatchRunProgressbarOverlay, $gfontsBatchRunProgressbarWrapper, and $gfontsBatchRunProgressbar are global variables so don't use "var" here … … 324 326 if ( 325 327 (returndataJSON.hasOwnProperty("httpStatus2") && 326 returndataJSON.httpStatus2 == 504) ||328 returndataJSON.httpStatus2 === 504) || 327 329 (returndataJSON.hasOwnProperty("httpStatus3") && 328 returndataJSON.httpStatus3 == 504)330 returndataJSON.httpStatus3 === 504) 329 331 ) { 330 332 //there was a timeout at some point during the communication with the Google Fonts server … … 368 370 $gfontsBatchRunProgressbar.progressbar("value", 100); 369 371 370 // if (thisRun == postdata.numRuns) {372 // if (thisRun === postdata.numRuns) { 371 373 // console.log("gfontsBatchRun has finished the job!"); 372 374 // } else { … … 461 463 //console.log('we should have an nonce for this action: '+gfontsBatch.gfontsRefreshNonce); 462 464 if ( 463 typeof gfontsBatch != "undefined" &&464 typeof gfontsBatch == "object" &&465 typeof gfontsBatch !== "undefined" && 466 typeof gfontsBatch === "object" && 465 467 gfontsBatch.hasOwnProperty("job") && 466 typeof gfontsBatch.job == "object" &&468 typeof gfontsBatch.job === "object" && 467 469 gfontsBatch.job.hasOwnProperty("gfontsRefreshNonce") && 468 gfontsBatch.job.gfontsRefreshNonce != "" &&470 gfontsBatch.job.gfontsRefreshNonce !== "" && 469 471 gfontsBatch.job.hasOwnProperty("gfontsApiKey") && 470 gfontsBatch.job.gfontsApiKey != ""472 gfontsBatch.job.gfontsApiKey !== "" 471 473 ) { 472 474 const postProps = { -
bibleget-io/trunk/vendor/composer/installed.php
r3040906 r3040959 2 2 'root' => array( 3 3 'name' => 'johnrdorazio/bibleget-wordpress', 4 'pretty_version' => '8. 2',5 'version' => '8. 2.0.0',6 'reference' => ' 442a7919a8a39ee149b5136f453972f664554573',4 'pretty_version' => '8.3', 5 'version' => '8.3.0.0', 6 'reference' => 'c1c96795fb7f3ab11fb8a4e3234130945b8458b6', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'johnrdorazio/bibleget-wordpress' => array( 14 'pretty_version' => '8. 2',15 'version' => '8. 2.0.0',16 'reference' => ' 442a7919a8a39ee149b5136f453972f664554573',14 'pretty_version' => '8.3', 15 'version' => '8.3.0.0', 16 'reference' => 'c1c96795fb7f3ab11fb8a4e3234130945b8458b6', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.