Plugin Directory

Changeset 3040959


Ignore:
Timestamp:
02/26/2024 02:43:25 AM (2 years ago)
Author:
Lwangaman
Message:

Update to version 8.3 from GitHub

Location:
bibleget-io
Files:
2 added
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • bibleget-io/tags/8.3/bibleget-io.php

    r3040906 r3040959  
    44 * Plugin URI: https://www.bibleget.io/
    55 * 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.2
     6 * Version: 8.3
    77 * Requires at least: 5.6
    88 * Requires PHP: 7.4
     
    3131
    3232
    33 define("BIBLEGETPLUGINVERSION", "v8_2");
     33define("BIBLEGETPLUGINVERSION", "v8_3");
    3434
    3535if (!defined('ABSPATH')) {
     
    144144    }
    145145    */
     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    }
    146157}
    147158
     
    171182 */
    172183function 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');
     189add_action( 'enqueue_block_editor_assets', 'bibleget_set_script_translations' );
    176190
    177191
     
    664678        }
    665679    }
    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 );
    670684    }
    671685}
  • bibleget-io/tags/8.3/includes/BibleGetSettingsPage.php

    r3040715 r3040959  
    182182            $lang = $this->locale;
    183183        }
    184         if (strlen($lang) == 2) {
     184        if (strlen($lang) === 2) {
    185185            //we have a two-letter ISO code, we need to get the full language name in English
    186186            if (extension_loaded('intl') === true) {
     
    265265    public function admin_print_styles($hook)
    266266    {
    267         if ($hook == 'settings_page_bibleget-settings-admin') {
     267        if ($hook === 'settings_page_bibleget-settings-admin') {
    268268            wp_enqueue_style('admin-css', plugins_url('../css/admin.css', __FILE__));
    269269        }
     
    289289        wp_enqueue_script('admin-js');
    290290
    291         if ($this->gfontsAPIkeyCheckResult == "SUCCESS") {
     291        if ($this->gfontsAPIkeyCheckResult === "SUCCESS") {
    292292            //We only want the transient to be set from the bibleget settings page, so we wait until now
    293293            // instead of doing it in the gfontsAPIkeyCheck (which is called on any admin interface)
    294294            set_transient(md5($this->options['googlefontsapi_key']), $this->gfontsAPIkeyCheckResult, 90 * 24 * HOUR_IN_SECONDS); // 90 giorni
    295295
    296             $plugin_path = "";
    297296            // bibleGetWriteLog("about to initialize creation of admin page...");
    298297            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());
    300300                /* initialize the API */
    301301                if (WP_Filesystem($creds)) {
    302302                    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)) {
    305304                        /* 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) {
    307306                            $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                            }
    308319                        }
    309320                    }
    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                     }
    316321
    317322                    //let's also cache the results from the Google Fonts API in a local file so we don't have to keep calling
    318323                    if ($wp_filesystem->put_contents(
    319                         $plugin_path . '../gfonts_preview/gfontsWeblist.json',
     324                        $gfontsDir . 'gfontsWeblist.json',
    320325                        json_encode($this->gfonts_weblist),
    321326                        FS_CHMOD_FILE // predefined mode settings for WP files
     
    330335            }
    331336            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                );
    333350            }
    334351            wp_enqueue_script('jquery-ui-progressbar');
     
    571588                    echo '<span style="color:DarkViolet;font-weight:bold;margin-left:12px;">' . __("CURL ERROR WHEN SENDING REQUEST", "bibleget-io") . '</span><br />';
    572589                    foreach ($this->gfontsAPI_errors as $er) {
    573                         if ($er == 403) {
     590                        if ($er === 403) {
    574591                            echo '<br /><i style="color:DarkViolet;margin-left:12px;">';
    575592                            echo __("This server's IP address has not been given access to the Google Fonts API using this key.", "bibleget-io");
     
    659676                    $response = curl_exec($ch);
    660677                    $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
    661                     if ($response && !curl_errno($ch) && $status == 200) {
     678                    if ($response && !curl_errno($ch) && $status === 200) {
    662679                        //let's see what was returned, and if it's what we're looking for
    663680                        $json_response = json_decode($response);
    664681                        if ($json_response !== null && json_last_error() === JSON_ERROR_NONE) {
    665682                            //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")) {
    667684                                $this->gfonts_weblist = $json_response;
    668685                                $result = "SUCCESS";
     
    680697                        }
    681698                        if ($status != 200) {
    682                             if ($status == 403) {
     699                            if ($status === 403) {
    683700                                $this->gfontsAPI_errors[] = $status;
    684701                            } else {
     
    723740        $familyfilename     = "";
    724741        $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";
    726744        $gfontsWeblist      = new stdClass();
    727745        $returnInfo         = new stdClass();
    728746
    729         if (file_exists($gfontsDir . "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);
    732750        }
    733751        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        {
    736761            //$gfontsCount = intval($_POST["gfontsCount"]);
    737762            $batchLimit = intval($_POST["batchLimit"]);
     
    748773        }
    749774
    750         $plugin_path = "";
    751775        if (get_filesystem_method() === 'direct') {
    752776            $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, array());
     
    754778            if (WP_Filesystem($creds)) {
    755779                global $wp_filesystem;
    756                 $plugin_path = str_replace('\\','/', plugin_dir_path( __FILE__ ) );
    757780
    758781                foreach ($gfontsWeblist->items as $idx => $googlefont) {
     
    764787                        $fnttype = 'ttf'; //'woff', 'woff2', 'ttf'
    765788
    766                         if (!file_exists($gfontsDir . "{$familyfilename}.{$fnttype}")) { //$idx < $idxlimit &&
     789                        if (!file_exists($gfontsDir . "ttf/{$familyfilename}.{$fnttype}")) { //$idx < $idxlimit &&
    767790                            $ch2 = curl_init("https://fonts.googleapis.com/css2?family={$familyurlname}&text={$familyfilename}");
    768791                            curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, TRUE);
     
    780803                            $status2 = (int) curl_getinfo($ch2, CURLINFO_HTTP_CODE);
    781804                            $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) {
    784807                                    $thisfonturl = $match[1];
    785808                                    $errorinfo[] = "font retrieval url for {$thisfamily} = {$thisfonturl}";
    786809
    787                                     //                         $ch3_headers = [];
     810                                    //$ch3_headers = [];
    788811                                    $ch3 = curl_init($thisfonturl);
    789812                                    curl_setopt($ch3, CURLOPT_SSL_VERIFYPEER, TRUE);
     
    802825                                    }
    803826                                    $response3 = curl_exec($ch3);
    804                                     //                $errorinfo[] = print_r($ch3_headers,TRUE);
     827                                    //$errorinfo[] = print_r($ch3_headers,TRUE);
    805828                                    $status3 = (int) curl_getinfo($ch3, CURLINFO_HTTP_CODE);
    806829                                    $returnInfo->httpStatus3 = $status3;
    807                                     if ($response3 && !curl_errno($ch3) && $status3 == 200) {
     830                                    if ($response3 && !curl_errno($ch3) && $status3 === 200) {
    808831                                        if ($wp_filesystem) {
    809                                             //if(!file_exists($plugin_path . "../gfonts_preview/{$familyfilename}.{$fnttype}") ){
     832                                            //if(!file_exists($gfontsDir . "ttf/{$familyfilename}.{$fnttype}") ){
    810833                                            if (!$wp_filesystem->put_contents(
    811                                                 $gfontsDir . "{$familyfilename}.{$fnttype}",
     834                                                $gfontsDir . "ttf/{$familyfilename}.{$fnttype}",
    812835                                                $response3,
    813836                                                FS_CHMOD_FILE
    814837                                            )) {
    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";
    816839                                            } 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")) {
    819843                                                    if (!$wp_filesystem->put_contents(
    820                                                         $plugin_path . "../css/gfonts_preview/{$familyfilename}.css",
     844                                                        $gfontsDir . "css/{$familyfilename}.css",
    821845                                                        $gfont_stylesheet,
    822846                                                        FS_CHMOD_FILE
    823847                                                    )) {
    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";
    825849                                                    }
    826850                                                }
     
    863887
    864888
    865         //         echo print_r($errorinfo);
     889        //echo print_r($errorinfo);
    866890        if (($startIdx + ($batchLimit - 1)) < ($totalFonts - 1)) {
    867891            $returnInfo->state = "RUN_PROCESSED";
     
    871895
    872896            //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";
    874898            $cssfiles = array_diff(scandir($cssdirectory), array('..', '.', 'gfonts_preview.css'));
    875 
    876899            $minifier = new MatthiasMullie\Minify\CSS($cssdirectory . "/" . (array_shift($cssfiles)));
    877900            while (count($cssfiles) > 0) {
  • bibleget-io/tags/8.3/includes/custom_controls.php

    r3037594 r3040959  
    9090                    );
    9191
    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 );
    9696            }
    9797            else{
  • bibleget-io/tags/8.3/js/admin.js

    r3040715 r3040959  
    6464            },
    6565            success: (returndata) => {
    66                 if (returndata == "datarefreshed") {
     66                if (returndata === "datarefreshed") {
    6767                    jQuery("#bibleget-settings-notification")
    6868                        .append(
     
    7373                            let interval1 = setInterval(() => {
    7474                                jQuery("#bibleget-countdown").text(
    75                                     --seconds + (seconds == 1 ? " sec..." : " secs...")
     75                                    --seconds + (seconds === 1 ? " sec..." : " secs...")
    7676                                );
    7777                            }, 1000);
     
    114114            },
    115115            success: (returndata) => {
    116                 if (returndata == "cacheflushed") {
     116                if (returndata === "cacheflushed") {
    117117                    jQuery("#bibleget-settings-notification")
    118118                        .append("Bible quotes cache emptied successfully")
     
    146146        gfontsBatch.job.gfontsPreviewJob === true &&
    147147        gfontsBatch.job.hasOwnProperty("gfontsWeblist") &&
    148         typeof gfontsBatch.job.gfontsWeblist == "object" &&
     148        typeof gfontsBatch.job.gfontsWeblist === "object" &&
    149149        gfontsBatch.job.gfontsWeblist.hasOwnProperty("items")
    150150    ) {
     
    160160                    $("<div>", {
    161161                        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>'),
    163163                        style:
    164164                            "color: white; background-color: red; padding: 3px 9px; display: inline-block; font-weight: bold; font-family: sans-serif;",
     
    186186                //console.log('batchLimit = '+batchLimit);
    187187            }
     188            //We actually need to run one more time than the batchlimit, in order for the minify stage to take place
     189            numRuns++;
    188190
    189191            //$gfontsBatchRunProgressbarOverlay, $gfontsBatchRunProgressbarWrapper, and $gfontsBatchRunProgressbar are global variables so don't use "var" here
     
    324326                    if (
    325327                        (returndataJSON.hasOwnProperty("httpStatus2") &&
    326                             returndataJSON.httpStatus2 == 504) ||
     328                            returndataJSON.httpStatus2 === 504) ||
    327329                        (returndataJSON.hasOwnProperty("httpStatus3") &&
    328                             returndataJSON.httpStatus3 == 504)
     330                            returndataJSON.httpStatus3 === 504)
    329331                    ) {
    330332                        //there was a timeout at some point during the communication with the Google Fonts server
     
    368370                            $gfontsBatchRunProgressbar.progressbar("value", 100);
    369371
    370                             // if (thisRun == postdata.numRuns) {
     372                            // if (thisRun === postdata.numRuns) {
    371373                            //   console.log("gfontsBatchRun has finished the job!");
    372374                            // } else {
     
    461463    //console.log('we should have an nonce for this action: '+gfontsBatch.gfontsRefreshNonce);
    462464    if (
    463         typeof gfontsBatch != "undefined" &&
    464         typeof gfontsBatch == "object" &&
     465        typeof gfontsBatch !== "undefined" &&
     466        typeof gfontsBatch === "object" &&
    465467        gfontsBatch.hasOwnProperty("job") &&
    466         typeof gfontsBatch.job == "object" &&
     468        typeof gfontsBatch.job === "object" &&
    467469        gfontsBatch.job.hasOwnProperty("gfontsRefreshNonce") &&
    468         gfontsBatch.job.gfontsRefreshNonce != "" &&
     470        gfontsBatch.job.gfontsRefreshNonce !== "" &&
    469471        gfontsBatch.job.hasOwnProperty("gfontsApiKey") &&
    470         gfontsBatch.job.gfontsApiKey != ""
     472        gfontsBatch.job.gfontsApiKey !== ""
    471473    ) {
    472474        const postProps = {
  • bibleget-io/tags/8.3/vendor/composer/installed.php

    r3040906 r3040959  
    22    'root' => array(
    33        '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',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        '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',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
  • bibleget-io/trunk/bibleget-io.php

    r3040906 r3040959  
    44 * Plugin URI: https://www.bibleget.io/
    55 * 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.2
     6 * Version: 8.3
    77 * Requires at least: 5.6
    88 * Requires PHP: 7.4
     
    3131
    3232
    33 define("BIBLEGETPLUGINVERSION", "v8_2");
     33define("BIBLEGETPLUGINVERSION", "v8_3");
    3434
    3535if (!defined('ABSPATH')) {
     
    144144    }
    145145    */
     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    }
    146157}
    147158
     
    171182 */
    172183function 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');
     189add_action( 'enqueue_block_editor_assets', 'bibleget_set_script_translations' );
    176190
    177191
     
    664678        }
    665679    }
    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 );
    670684    }
    671685}
  • bibleget-io/trunk/includes/BibleGetSettingsPage.php

    r3040715 r3040959  
    182182            $lang = $this->locale;
    183183        }
    184         if (strlen($lang) == 2) {
     184        if (strlen($lang) === 2) {
    185185            //we have a two-letter ISO code, we need to get the full language name in English
    186186            if (extension_loaded('intl') === true) {
     
    265265    public function admin_print_styles($hook)
    266266    {
    267         if ($hook == 'settings_page_bibleget-settings-admin') {
     267        if ($hook === 'settings_page_bibleget-settings-admin') {
    268268            wp_enqueue_style('admin-css', plugins_url('../css/admin.css', __FILE__));
    269269        }
     
    289289        wp_enqueue_script('admin-js');
    290290
    291         if ($this->gfontsAPIkeyCheckResult == "SUCCESS") {
     291        if ($this->gfontsAPIkeyCheckResult === "SUCCESS") {
    292292            //We only want the transient to be set from the bibleget settings page, so we wait until now
    293293            // instead of doing it in the gfontsAPIkeyCheck (which is called on any admin interface)
    294294            set_transient(md5($this->options['googlefontsapi_key']), $this->gfontsAPIkeyCheckResult, 90 * 24 * HOUR_IN_SECONDS); // 90 giorni
    295295
    296             $plugin_path = "";
    297296            // bibleGetWriteLog("about to initialize creation of admin page...");
    298297            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());
    300300                /* initialize the API */
    301301                if (WP_Filesystem($creds)) {
    302302                    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)) {
    305304                        /* 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) {
    307306                            $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                            }
    308319                        }
    309320                    }
    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                     }
    316321
    317322                    //let's also cache the results from the Google Fonts API in a local file so we don't have to keep calling
    318323                    if ($wp_filesystem->put_contents(
    319                         $plugin_path . '../gfonts_preview/gfontsWeblist.json',
     324                        $gfontsDir . 'gfontsWeblist.json',
    320325                        json_encode($this->gfonts_weblist),
    321326                        FS_CHMOD_FILE // predefined mode settings for WP files
     
    330335            }
    331336            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                );
    333350            }
    334351            wp_enqueue_script('jquery-ui-progressbar');
     
    571588                    echo '<span style="color:DarkViolet;font-weight:bold;margin-left:12px;">' . __("CURL ERROR WHEN SENDING REQUEST", "bibleget-io") . '</span><br />';
    572589                    foreach ($this->gfontsAPI_errors as $er) {
    573                         if ($er == 403) {
     590                        if ($er === 403) {
    574591                            echo '<br /><i style="color:DarkViolet;margin-left:12px;">';
    575592                            echo __("This server's IP address has not been given access to the Google Fonts API using this key.", "bibleget-io");
     
    659676                    $response = curl_exec($ch);
    660677                    $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
    661                     if ($response && !curl_errno($ch) && $status == 200) {
     678                    if ($response && !curl_errno($ch) && $status === 200) {
    662679                        //let's see what was returned, and if it's what we're looking for
    663680                        $json_response = json_decode($response);
    664681                        if ($json_response !== null && json_last_error() === JSON_ERROR_NONE) {
    665682                            //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")) {
    667684                                $this->gfonts_weblist = $json_response;
    668685                                $result = "SUCCESS";
     
    680697                        }
    681698                        if ($status != 200) {
    682                             if ($status == 403) {
     699                            if ($status === 403) {
    683700                                $this->gfontsAPI_errors[] = $status;
    684701                            } else {
     
    723740        $familyfilename     = "";
    724741        $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";
    726744        $gfontsWeblist      = new stdClass();
    727745        $returnInfo         = new stdClass();
    728746
    729         if (file_exists($gfontsDir . "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);
    732750        }
    733751        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        {
    736761            //$gfontsCount = intval($_POST["gfontsCount"]);
    737762            $batchLimit = intval($_POST["batchLimit"]);
     
    748773        }
    749774
    750         $plugin_path = "";
    751775        if (get_filesystem_method() === 'direct') {
    752776            $creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, array());
     
    754778            if (WP_Filesystem($creds)) {
    755779                global $wp_filesystem;
    756                 $plugin_path = str_replace('\\','/', plugin_dir_path( __FILE__ ) );
    757780
    758781                foreach ($gfontsWeblist->items as $idx => $googlefont) {
     
    764787                        $fnttype = 'ttf'; //'woff', 'woff2', 'ttf'
    765788
    766                         if (!file_exists($gfontsDir . "{$familyfilename}.{$fnttype}")) { //$idx < $idxlimit &&
     789                        if (!file_exists($gfontsDir . "ttf/{$familyfilename}.{$fnttype}")) { //$idx < $idxlimit &&
    767790                            $ch2 = curl_init("https://fonts.googleapis.com/css2?family={$familyurlname}&text={$familyfilename}");
    768791                            curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, TRUE);
     
    780803                            $status2 = (int) curl_getinfo($ch2, CURLINFO_HTTP_CODE);
    781804                            $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) {
    784807                                    $thisfonturl = $match[1];
    785808                                    $errorinfo[] = "font retrieval url for {$thisfamily} = {$thisfonturl}";
    786809
    787                                     //                         $ch3_headers = [];
     810                                    //$ch3_headers = [];
    788811                                    $ch3 = curl_init($thisfonturl);
    789812                                    curl_setopt($ch3, CURLOPT_SSL_VERIFYPEER, TRUE);
     
    802825                                    }
    803826                                    $response3 = curl_exec($ch3);
    804                                     //                $errorinfo[] = print_r($ch3_headers,TRUE);
     827                                    //$errorinfo[] = print_r($ch3_headers,TRUE);
    805828                                    $status3 = (int) curl_getinfo($ch3, CURLINFO_HTTP_CODE);
    806829                                    $returnInfo->httpStatus3 = $status3;
    807                                     if ($response3 && !curl_errno($ch3) && $status3 == 200) {
     830                                    if ($response3 && !curl_errno($ch3) && $status3 === 200) {
    808831                                        if ($wp_filesystem) {
    809                                             //if(!file_exists($plugin_path . "../gfonts_preview/{$familyfilename}.{$fnttype}") ){
     832                                            //if(!file_exists($gfontsDir . "ttf/{$familyfilename}.{$fnttype}") ){
    810833                                            if (!$wp_filesystem->put_contents(
    811                                                 $gfontsDir . "{$familyfilename}.{$fnttype}",
     834                                                $gfontsDir . "ttf/{$familyfilename}.{$fnttype}",
    812835                                                $response3,
    813836                                                FS_CHMOD_FILE
    814837                                            )) {
    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";
    816839                                            } 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")) {
    819843                                                    if (!$wp_filesystem->put_contents(
    820                                                         $plugin_path . "../css/gfonts_preview/{$familyfilename}.css",
     844                                                        $gfontsDir . "css/{$familyfilename}.css",
    821845                                                        $gfont_stylesheet,
    822846                                                        FS_CHMOD_FILE
    823847                                                    )) {
    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";
    825849                                                    }
    826850                                                }
     
    863887
    864888
    865         //         echo print_r($errorinfo);
     889        //echo print_r($errorinfo);
    866890        if (($startIdx + ($batchLimit - 1)) < ($totalFonts - 1)) {
    867891            $returnInfo->state = "RUN_PROCESSED";
     
    871895
    872896            //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";
    874898            $cssfiles = array_diff(scandir($cssdirectory), array('..', '.', 'gfonts_preview.css'));
    875 
    876899            $minifier = new MatthiasMullie\Minify\CSS($cssdirectory . "/" . (array_shift($cssfiles)));
    877900            while (count($cssfiles) > 0) {
  • bibleget-io/trunk/includes/custom_controls.php

    r3037594 r3040959  
    9090                    );
    9191
    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 );
    9696            }
    9797            else{
  • bibleget-io/trunk/js/admin.js

    r3040715 r3040959  
    6464            },
    6565            success: (returndata) => {
    66                 if (returndata == "datarefreshed") {
     66                if (returndata === "datarefreshed") {
    6767                    jQuery("#bibleget-settings-notification")
    6868                        .append(
     
    7373                            let interval1 = setInterval(() => {
    7474                                jQuery("#bibleget-countdown").text(
    75                                     --seconds + (seconds == 1 ? " sec..." : " secs...")
     75                                    --seconds + (seconds === 1 ? " sec..." : " secs...")
    7676                                );
    7777                            }, 1000);
     
    114114            },
    115115            success: (returndata) => {
    116                 if (returndata == "cacheflushed") {
     116                if (returndata === "cacheflushed") {
    117117                    jQuery("#bibleget-settings-notification")
    118118                        .append("Bible quotes cache emptied successfully")
     
    146146        gfontsBatch.job.gfontsPreviewJob === true &&
    147147        gfontsBatch.job.hasOwnProperty("gfontsWeblist") &&
    148         typeof gfontsBatch.job.gfontsWeblist == "object" &&
     148        typeof gfontsBatch.job.gfontsWeblist === "object" &&
    149149        gfontsBatch.job.gfontsWeblist.hasOwnProperty("items")
    150150    ) {
     
    160160                    $("<div>", {
    161161                        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>'),
    163163                        style:
    164164                            "color: white; background-color: red; padding: 3px 9px; display: inline-block; font-weight: bold; font-family: sans-serif;",
     
    186186                //console.log('batchLimit = '+batchLimit);
    187187            }
     188            //We actually need to run one more time than the batchlimit, in order for the minify stage to take place
     189            numRuns++;
    188190
    189191            //$gfontsBatchRunProgressbarOverlay, $gfontsBatchRunProgressbarWrapper, and $gfontsBatchRunProgressbar are global variables so don't use "var" here
     
    324326                    if (
    325327                        (returndataJSON.hasOwnProperty("httpStatus2") &&
    326                             returndataJSON.httpStatus2 == 504) ||
     328                            returndataJSON.httpStatus2 === 504) ||
    327329                        (returndataJSON.hasOwnProperty("httpStatus3") &&
    328                             returndataJSON.httpStatus3 == 504)
     330                            returndataJSON.httpStatus3 === 504)
    329331                    ) {
    330332                        //there was a timeout at some point during the communication with the Google Fonts server
     
    368370                            $gfontsBatchRunProgressbar.progressbar("value", 100);
    369371
    370                             // if (thisRun == postdata.numRuns) {
     372                            // if (thisRun === postdata.numRuns) {
    371373                            //   console.log("gfontsBatchRun has finished the job!");
    372374                            // } else {
     
    461463    //console.log('we should have an nonce for this action: '+gfontsBatch.gfontsRefreshNonce);
    462464    if (
    463         typeof gfontsBatch != "undefined" &&
    464         typeof gfontsBatch == "object" &&
     465        typeof gfontsBatch !== "undefined" &&
     466        typeof gfontsBatch === "object" &&
    465467        gfontsBatch.hasOwnProperty("job") &&
    466         typeof gfontsBatch.job == "object" &&
     468        typeof gfontsBatch.job === "object" &&
    467469        gfontsBatch.job.hasOwnProperty("gfontsRefreshNonce") &&
    468         gfontsBatch.job.gfontsRefreshNonce != "" &&
     470        gfontsBatch.job.gfontsRefreshNonce !== "" &&
    469471        gfontsBatch.job.hasOwnProperty("gfontsApiKey") &&
    470         gfontsBatch.job.gfontsApiKey != ""
     472        gfontsBatch.job.gfontsApiKey !== ""
    471473    ) {
    472474        const postProps = {
  • bibleget-io/trunk/vendor/composer/installed.php

    r3040906 r3040959  
    22    'root' => array(
    33        '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',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        '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',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.