Plugin Directory

Changeset 2743703


Ignore:
Timestamp:
06/16/2022 04:57:15 PM (4 years ago)
Author:
navigationnorth
Message:

Update to version 0.9.1 from GitHub

Location:
wp-oer
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-oer/tags/0.9.1/includes/oer-functions.php

    r2742932 r2743703  
    10461046    $cnt = 0;
    10471047        try{
     1048            // Register our path override.
     1049            add_filter( 'upload_dir', 'oer_override_upload_dir' );
     1050            $upload_overrides = array(
     1051                'test_form' => false,
     1052                'unique_filename_callback' => 'oer_override_filename');
     1053           
    10481054            if ($default==true) {
    10491055                //default resource filename
     
    10661072                            mkdir(OER_PATH."upload",0777);
    10671073                        }
     1074                        $_file = wp_handle_upload($_FILES["resource_import"], $upload_overrides);
    10681075                        "Upload: " . sanitize_file_name($_FILES["resource_import"]["name"]) . "<br>";
    10691076                        "Type: " . sanitize_text_field($_FILES["resource_import"]["type"]) . "<br>";
    10701077                        "Size: " . sanitize_text_field(($_FILES["resource_import"]["size"] / 1024)) . " kB<br>";
    1071                         "stored in:" .move_uploaded_file($_FILES["resource_import"]["tmp_name"],OER_PATH."upload/".$filename) ;
    1072                     }
    1073                     $excl_obj->read(OER_PATH."upload/".$filename);
     1078                        "stored in:" . $_file['file'];
     1079                    }
     1080                   
     1081                    $excl_obj->read($_file['file']);
    10741082                }
    10751083            }
     1084            // Set upload dir to normal
     1085            remove_filter( 'upload_dir', 'oer_override_upload_dir' );
    10761086
    10771087            $fnldata = $excl_obj->sheets[0];
     
    17181728}
    17191729
     1730// Temporarily override upload dir of wp_handle_upload
     1731function oer_override_upload_dir( $dir ){
     1732     return array(
     1733        'path'   => OER_PATH."upload",
     1734        'url'    => OER_PATH."upload",
     1735        'subdir' => '/upload',
     1736    ) + $dir;
     1737}
     1738
     1739// Override filename for wp_handle_upload
     1740function oer_override_filename($dir, $name, $ext){
     1741    $time = time();
     1742    $date = date($time);
     1743    $file = pathinfo($name);
     1744    $new_filename = $file['filename'] . "-" . $date . $ext;
     1745    return $new_filename;
     1746}
     1747
    17201748//Import Subject Areas
    17211749function oer_importSubjectAreas($default=false) {
     
    17391767
    17401768    global $wpdb;
     1769
     1770    // Register our path override.
     1771    add_filter( 'upload_dir', 'oer_override_upload_dir' );
     1772    $upload_overrides = array(
     1773        'test_form' => false,
     1774        'unique_filename_callback' => 'oer_override_filename');
    17411775
    17421776    try {
     
    17581792                {
    17591793                    //Upload File
    1760                     "Upload: " . sanitize_file_name($_FILES["bulk_import"]["name"]) . "<br>";
     1794                    $_file = wp_handle_upload($_FILES["bulk_import"], $upload_overrides);
     1795                    "Upload: " . sanitize_file_name($_FILES["bulk_import"]["name"]) . "<br>";
    17611796                    "Type: " . sanitize_text_field($_FILES["bulk_import"]["type"]) . "<br>";
    17621797                    "Size: " . sanitize_text_field(($_FILES["bulk_import"]["size"] / 1024)) . " kB<br>";
    1763                     "stored in:" .move_uploaded_file($_FILES["bulk_import"]["tmp_name"],OER_PATH."upload/".$filename) ;
     1798                    "stored in:" . esc_url_raw($_file['file']) ;
    17641799                }
    17651800
    17661801                //Read Excel Data
    1767                 $excl_obj->read(OER_PATH."upload/".$filename);
     1802                //$excl_obj->read(OER_PATH."upload/".$filename);
     1803                $excl_obj->read($_file['file']);
    17681804            }
    17691805        }
     1806        // Set upload dir to normal
     1807        remove_filter( 'upload_dir', 'oer_override_upload_dir' );
    17701808
    17711809            $fnldata = $excl_obj->sheets;
     
    18521890    return $response;
    18531891}
     1892
     1893
    18541894
    18551895//Import Default Grade Levels
     
    26132653    $substandards = array();
    26142654   
    2615     $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards where parent_id='%s'";
     2655    $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards where parent_id = %s";
    26162656   
    26172657    $substandards = $wpdb->get_results($wpdb->prepare($query, $std_id));
     
    26302670    $notations = array();
    26312671   
    2632     $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation where parent_id='%s'";
     2672    $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation where parent_id = %s";
    26332673   
    26342674    $result = $wpdb->get_results($wpdb->prepare($query, $std_id));
     
    26492689    $std = null;
    26502690   
    2651     $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";
     2691    $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s";
    26522692   
    26532693    $substandards = $wpdb->get_results($wpdb->prepare($query, $notation));
     
    26682708    $std = null;
    26692709   
    2670     $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";
     2710    $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s";
    26712711   
    26722712    $standard_notation = $wpdb->get_results($wpdb->prepare($query, $notation));
     
    26972737    $std = null;
    26982738   
    2699     $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";
     2739    $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s";
    27002740   
    27012741    $standard_notation = $wpdb->get_results($wpdb->prepare($query, $notation));
     
    27592799    $notation = "standard_notation-".$notation_id;
    27602800   
    2761     $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE parent_id = '%s'";
     2801    $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE parent_id = %s";
    27622802   
    27632803    $standard_notations = $wpdb->get_results($wpdb->prepare($query, $notation));
     
    28582898    $parent = explode("-",$parent_id);
    28592899    if ($parent[0]=="sub_standards") {
    2860         $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards WHERE id = '%s'";
     2900        $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards WHERE id = %s";
    28612901        $substandards = $wpdb->get_results($wpdb->prepare($query, $parent[1]));
    28622902       
     
    28652905        }
    28662906    } else {
    2867         $query = "SELECT * FROM {$wpdb->prefix}oer_core_standards WHERE id = '%s'";
     2907        $query = "SELECT * FROM {$wpdb->prefix}oer_core_standards WHERE id = %s";
    28682908        $standards = $wpdb->get_results($wpdb->prepare($query, $parent[1]));
    28692909        foreach($standards as $std){
  • wp-oer/tags/0.9.1/open-educational-resources.php

    r2742932 r2743703  
    44 Plugin URI:         https://www.wp-oer.com
    55 Description:        Open Educational Resource management and curation, metadata publishing, and alignment to Common Core State Standards.
    6  Version:            0.9.0
     6 Version:            0.9.1
    77 Requires at least:  4.4
    88 Requires PHP:       7.0
     
    3939define( 'OER_PLUGIN_NAME', 'WP OER Plugin' );
    4040define( 'OER_ADMIN_PLUGIN_NAME', 'WP OER Plugin');
    41 define( 'OER_VERSION', '0.9.0' );
     41define( 'OER_VERSION', '0.9.1' );
    4242define( 'OER_SITE_PATH', ABSPATH );
    4343
     
    21562156
    21572157        //Search in title
    2158         $search .= $wpdb->prepare("($wpdb->posts.post_title LIKE '%s')", $term);
     2158        $search .= $wpdb->prepare("($wpdb->posts.post_title LIKE %s)", $term);
    21592159                $OR = ' OR ';
    21602160
    21612161        //Search in content
    21622162        $search .= $OR;
    2163                 $search .= $wpdb->prepare("($wpdb->posts.post_content LIKE '%s')", $term);
     2163                $search .= $wpdb->prepare("($wpdb->posts.post_content LIKE %s)", $term);
    21642164                $OR = ' OR ';
    21652165
     
    21902190        foreach ($meta_keys as $key_slug) {
    21912191                        $search .= $OR;
    2192                         $search .= $wpdb->prepare("$meta_key_OR (pm.meta_key = '%s' AND pm.meta_value LIKE '%s')", $key_slug, $term);
     2192                        $search .= $wpdb->prepare("$meta_key_OR (pm.meta_key = %s AND pm.meta_value LIKE %s)", $key_slug, $term);
    21932193                        $OR = '';
    21942194                        $meta_key_OR = ' OR ';
     
    22022202        foreach($taxonomies as $tax) {
    22032203            $search .= $OR;
    2204                         $search .= $wpdb->prepare("$tax_OR (tt.taxonomy = '%s' AND t.name LIKE '%s')", $tax, $term);
     2204                        $search .= $wpdb->prepare("$tax_OR (tt.taxonomy = %s AND t.name LIKE %s)", $tax, $term);
    22052205                        $OR = '';
    22062206                        $tax_OR = ' OR ';
  • wp-oer/tags/0.9.1/readme.txt

    r2742932 r2743703  
    55Tested up to: 6.0
    66Requires PHP: 7.0
    7 Stable tag: 0.9.0
     7Stable tag: 0.9.1
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    4242
    4343== Changelog ==
     44= 0.9.1 =
     45* Replaced move_uploaded_file with wp_handle_upload function when importing subject areas and resources
     46* Removed quote around string placeholders used in $wpdb->prepare statements
     47
    4448= 0.9.0 =
    45 * Implement further sanitizing of input and escaping of displayed data
     49* Implemented further sanitizing of input and escaping of displayed data
    4650
    4751= 0.8.9 =
  • wp-oer/trunk/includes/oer-functions.php

    r2742932 r2743703  
    10461046    $cnt = 0;
    10471047        try{
     1048            // Register our path override.
     1049            add_filter( 'upload_dir', 'oer_override_upload_dir' );
     1050            $upload_overrides = array(
     1051                'test_form' => false,
     1052                'unique_filename_callback' => 'oer_override_filename');
     1053           
    10481054            if ($default==true) {
    10491055                //default resource filename
     
    10661072                            mkdir(OER_PATH."upload",0777);
    10671073                        }
     1074                        $_file = wp_handle_upload($_FILES["resource_import"], $upload_overrides);
    10681075                        "Upload: " . sanitize_file_name($_FILES["resource_import"]["name"]) . "<br>";
    10691076                        "Type: " . sanitize_text_field($_FILES["resource_import"]["type"]) . "<br>";
    10701077                        "Size: " . sanitize_text_field(($_FILES["resource_import"]["size"] / 1024)) . " kB<br>";
    1071                         "stored in:" .move_uploaded_file($_FILES["resource_import"]["tmp_name"],OER_PATH."upload/".$filename) ;
    1072                     }
    1073                     $excl_obj->read(OER_PATH."upload/".$filename);
     1078                        "stored in:" . $_file['file'];
     1079                    }
     1080                   
     1081                    $excl_obj->read($_file['file']);
    10741082                }
    10751083            }
     1084            // Set upload dir to normal
     1085            remove_filter( 'upload_dir', 'oer_override_upload_dir' );
    10761086
    10771087            $fnldata = $excl_obj->sheets[0];
     
    17181728}
    17191729
     1730// Temporarily override upload dir of wp_handle_upload
     1731function oer_override_upload_dir( $dir ){
     1732     return array(
     1733        'path'   => OER_PATH."upload",
     1734        'url'    => OER_PATH."upload",
     1735        'subdir' => '/upload',
     1736    ) + $dir;
     1737}
     1738
     1739// Override filename for wp_handle_upload
     1740function oer_override_filename($dir, $name, $ext){
     1741    $time = time();
     1742    $date = date($time);
     1743    $file = pathinfo($name);
     1744    $new_filename = $file['filename'] . "-" . $date . $ext;
     1745    return $new_filename;
     1746}
     1747
    17201748//Import Subject Areas
    17211749function oer_importSubjectAreas($default=false) {
     
    17391767
    17401768    global $wpdb;
     1769
     1770    // Register our path override.
     1771    add_filter( 'upload_dir', 'oer_override_upload_dir' );
     1772    $upload_overrides = array(
     1773        'test_form' => false,
     1774        'unique_filename_callback' => 'oer_override_filename');
    17411775
    17421776    try {
     
    17581792                {
    17591793                    //Upload File
    1760                     "Upload: " . sanitize_file_name($_FILES["bulk_import"]["name"]) . "<br>";
     1794                    $_file = wp_handle_upload($_FILES["bulk_import"], $upload_overrides);
     1795                    "Upload: " . sanitize_file_name($_FILES["bulk_import"]["name"]) . "<br>";
    17611796                    "Type: " . sanitize_text_field($_FILES["bulk_import"]["type"]) . "<br>";
    17621797                    "Size: " . sanitize_text_field(($_FILES["bulk_import"]["size"] / 1024)) . " kB<br>";
    1763                     "stored in:" .move_uploaded_file($_FILES["bulk_import"]["tmp_name"],OER_PATH."upload/".$filename) ;
     1798                    "stored in:" . esc_url_raw($_file['file']) ;
    17641799                }
    17651800
    17661801                //Read Excel Data
    1767                 $excl_obj->read(OER_PATH."upload/".$filename);
     1802                //$excl_obj->read(OER_PATH."upload/".$filename);
     1803                $excl_obj->read($_file['file']);
    17681804            }
    17691805        }
     1806        // Set upload dir to normal
     1807        remove_filter( 'upload_dir', 'oer_override_upload_dir' );
    17701808
    17711809            $fnldata = $excl_obj->sheets;
     
    18521890    return $response;
    18531891}
     1892
     1893
    18541894
    18551895//Import Default Grade Levels
     
    26132653    $substandards = array();
    26142654   
    2615     $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards where parent_id='%s'";
     2655    $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards where parent_id = %s";
    26162656   
    26172657    $substandards = $wpdb->get_results($wpdb->prepare($query, $std_id));
     
    26302670    $notations = array();
    26312671   
    2632     $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation where parent_id='%s'";
     2672    $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation where parent_id = %s";
    26332673   
    26342674    $result = $wpdb->get_results($wpdb->prepare($query, $std_id));
     
    26492689    $std = null;
    26502690   
    2651     $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";
     2691    $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s";
    26522692   
    26532693    $substandards = $wpdb->get_results($wpdb->prepare($query, $notation));
     
    26682708    $std = null;
    26692709   
    2670     $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";
     2710    $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s";
    26712711   
    26722712    $standard_notation = $wpdb->get_results($wpdb->prepare($query, $notation));
     
    26972737    $std = null;
    26982738   
    2699     $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";
     2739    $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s";
    27002740   
    27012741    $standard_notation = $wpdb->get_results($wpdb->prepare($query, $notation));
     
    27592799    $notation = "standard_notation-".$notation_id;
    27602800   
    2761     $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE parent_id = '%s'";
     2801    $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE parent_id = %s";
    27622802   
    27632803    $standard_notations = $wpdb->get_results($wpdb->prepare($query, $notation));
     
    28582898    $parent = explode("-",$parent_id);
    28592899    if ($parent[0]=="sub_standards") {
    2860         $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards WHERE id = '%s'";
     2900        $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards WHERE id = %s";
    28612901        $substandards = $wpdb->get_results($wpdb->prepare($query, $parent[1]));
    28622902       
     
    28652905        }
    28662906    } else {
    2867         $query = "SELECT * FROM {$wpdb->prefix}oer_core_standards WHERE id = '%s'";
     2907        $query = "SELECT * FROM {$wpdb->prefix}oer_core_standards WHERE id = %s";
    28682908        $standards = $wpdb->get_results($wpdb->prepare($query, $parent[1]));
    28692909        foreach($standards as $std){
  • wp-oer/trunk/open-educational-resources.php

    r2742932 r2743703  
    44 Plugin URI:         https://www.wp-oer.com
    55 Description:        Open Educational Resource management and curation, metadata publishing, and alignment to Common Core State Standards.
    6  Version:            0.9.0
     6 Version:            0.9.1
    77 Requires at least:  4.4
    88 Requires PHP:       7.0
     
    3939define( 'OER_PLUGIN_NAME', 'WP OER Plugin' );
    4040define( 'OER_ADMIN_PLUGIN_NAME', 'WP OER Plugin');
    41 define( 'OER_VERSION', '0.9.0' );
     41define( 'OER_VERSION', '0.9.1' );
    4242define( 'OER_SITE_PATH', ABSPATH );
    4343
     
    21562156
    21572157        //Search in title
    2158         $search .= $wpdb->prepare("($wpdb->posts.post_title LIKE '%s')", $term);
     2158        $search .= $wpdb->prepare("($wpdb->posts.post_title LIKE %s)", $term);
    21592159                $OR = ' OR ';
    21602160
    21612161        //Search in content
    21622162        $search .= $OR;
    2163                 $search .= $wpdb->prepare("($wpdb->posts.post_content LIKE '%s')", $term);
     2163                $search .= $wpdb->prepare("($wpdb->posts.post_content LIKE %s)", $term);
    21642164                $OR = ' OR ';
    21652165
     
    21902190        foreach ($meta_keys as $key_slug) {
    21912191                        $search .= $OR;
    2192                         $search .= $wpdb->prepare("$meta_key_OR (pm.meta_key = '%s' AND pm.meta_value LIKE '%s')", $key_slug, $term);
     2192                        $search .= $wpdb->prepare("$meta_key_OR (pm.meta_key = %s AND pm.meta_value LIKE %s)", $key_slug, $term);
    21932193                        $OR = '';
    21942194                        $meta_key_OR = ' OR ';
     
    22022202        foreach($taxonomies as $tax) {
    22032203            $search .= $OR;
    2204                         $search .= $wpdb->prepare("$tax_OR (tt.taxonomy = '%s' AND t.name LIKE '%s')", $tax, $term);
     2204                        $search .= $wpdb->prepare("$tax_OR (tt.taxonomy = %s AND t.name LIKE %s)", $tax, $term);
    22052205                        $OR = '';
    22062206                        $tax_OR = ' OR ';
  • wp-oer/trunk/readme.txt

    r2742932 r2743703  
    55Tested up to: 6.0
    66Requires PHP: 7.0
    7 Stable tag: 0.9.0
     7Stable tag: 0.9.1
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    4242
    4343== Changelog ==
     44= 0.9.1 =
     45* Replaced move_uploaded_file with wp_handle_upload function when importing subject areas and resources
     46* Removed quote around string placeholders used in $wpdb->prepare statements
     47
    4448= 0.9.0 =
    45 * Implement further sanitizing of input and escaping of displayed data
     49* Implemented further sanitizing of input and escaping of displayed data
    4650
    4751= 0.8.9 =
Note: See TracChangeset for help on using the changeset viewer.