Plugin Directory

Changeset 1776251


Ignore:
Timestamp:
11/27/2017 03:33:08 PM (8 years ago)
Author:
navigationnorth
Message:

updates for v0.5.9

Location:
wp-oer/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • wp-oer/trunk/css/front_styles.css

    r1714161 r1776251  
    411411.oer-rsrclftcntr-img { padding-left:0 !important; }
    412412.oer-rsrclftcntr { padding-left:0 !important; }
    413 
     413.videoWrapper {
     414    position: relative;
     415    padding-bottom: 56.25%; /* 16:9 */
     416    padding-top: 25px;
     417    height: 0;
     418}
     419.videoWrapper iframe {
     420    position: absolute;
     421    top: 0;
     422    left: 0;
     423    width: 100%;
     424    height: 100%;
     425}
     426.search-results #content .fusion-post-content .fusion-post-content-container p {
     427    display: block;
     428    display: -webkit-box;
     429    height: 6em;
     430    margin: 0 auto;
     431    -webkit-line-clamp: 3;
     432    -webkit-box-orient: vertical;
     433    overflow: hidden;
     434    text-overflow: ellipsis;
     435}
     436.search-results #content .fusion-post-content h2.fusion-post-title { margin-bottom:0; }
     437.search-results #content .fusion-post-content h5.fusion-post-meta { margin-bottom:25px; margin-top:0; }
     438.search-results #content .fusion-post-content h5.fusion-post-meta .fusion-post-meta-box { margin-right:15px; }
     439.search-results #content .fusion-post-content .fusion-subject-areas { overflow:hidden; margin-top:15px; }
     440.search-results #content .fusion-post-content .fusion-subject-areas span { margin-right:5px; }
     441.search-results .type-resource .entry-header h2.entry-title { margin-bottom:0; }
     442.search-results .type-resource .entry-header h5.post-meta { margin-bottom:1.05em; }
     443.search-results .type-resource .entry-header h5.post-meta .post-meta-box { margin-right:15px; }
    414444@media screen and (max-width: 600px) {
    415445    .oer_blgpst .oer-feature-image { width:100%; float:none; margin-bottom:10px; }
  • wp-oer/trunk/css/resource-style.css

    r1729969 r1776251  
    5959    height: 100%;
    6060}
     61.oer-sngl-rsrc-img .oer-rsrcurl.left { text-align:left; }
    6162/** For Mobile styles **/
    6263@media screen and (min-width: 960px) {
  • wp-oer/trunk/includes/init.php

    r1729969 r1776251  
    351351    if($post->post_type == 'resource')
    352352    {
     353        if (isset($_GET['action']) && ($_GET['action']=="trash" || $_GET['action']=="untrash")){
     354        return;
     355        }
    353356        if (!isset($_POST['oer_metabox_nonce_field']) || !wp_verify_nonce( $_POST['oer_metabox_nonce_field'], 'oer_metabox_action' )) {
    354         wp_die('Nonce verification failed');
     357            wp_die('Nonce verification failed');
    355358        }
    356359        if(isset($_POST['oer_resourceurl']))
     
    581584        {
    582585            $url = esc_url_raw($_POST['oer_resourceurl']);
     586           
     587            $youtube = oer_is_youtube_url($url);
     588           
    583589            $upload_dir = wp_upload_dir();
    584590            $file = '';
     
    593599                if ( $external_screenshot )
    594600                $file = oer_getImageFromExternalURL($url);
    595             }
    596 
     601               
     602                if ( $youtube )
     603                $file = oer_get_youtube_thumbnail($url);
     604            }
     605           
    597606            if(file_exists($file))
    598607            {
  • wp-oer/trunk/includes/oer-functions.php

    r1729969 r1776251  
    835835}
    836836
     837function oer_save_image_to_file($image_url) {
     838    $ch = curl_init ($image_url);
     839
     840    curl_setopt($ch, CURLOPT_HEADER, 0);
     841    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     842    curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
     843    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     844
     845    $raw=curl_exec($ch);
     846    curl_close ($ch);
     847
     848    $upload_dir = wp_upload_dir();
     849    $path = $upload_dir['basedir'].'/resource-images/';
     850
     851    if(!file_exists($path))
     852    {
     853        mkdir($path, 0777, true);
     854        debug_log("OER : create upload directory");
     855    }
     856
     857    if(!file_exists($file = $path.'Screenshot'.preg_replace('/https?|:|#|\?|\&|\//i', '-', $image_url).'.jpg'))
     858    {
     859        debug_log("OER : start screenshot function");
     860
     861        $fp = fopen($file,'wb');
     862        fwrite($fp, $raw);
     863        fclose($fp);
     864
     865        debug_log("OER : end of screenshot function");
     866    }
     867    return $file;
     868}
     869
    837870//Get External Thumbnail Image
    838871function oer_getExternalThumbnailImage($url, $local=false) {
     
    896929    $url = get_site_url();
    897930   
    898     $content = file_get_contents($url);
     931    if (ini_get('allow_url_fopen'))
     932        $content = file_get_contents($url);
     933    else
     934        $content = oer_curlRequest($url);
     935   
    899936    $content = htmlentities($content);
    900937   
     
    913950   
    914951    return $bootstrap;
     952}
     953
     954/** Get resource via curl **/
     955function oer_curlRequest($url) {
     956   $ch = curl_init();
     957   curl_setopt($ch, CURLOPT_URL, $url);
     958   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     959   $data = curl_exec($ch);
     960   curl_close($ch);
     961   return $data;
    915962}
    916963
     
    16471694    <div class="sort-box">
    16481695        <span class="sortoption"></span>
    1649         <span class="sort-resources" title="Sort stories"><i class="fa fa-sort" aria-hidden="true"></i></span>
     1696        <span class="sort-resources" title="Sort stories" tabindex="0" role="button"><i class="fa fa-sort" aria-hidden="true"></i></span>
    16501697        <div class="sort-options">
    16511698            <ul>
     
    19612008//Generate youtube embed code
    19622009function oer_generate_youtube_embed_code($url) {
    1963     $youtube_id = "";
    19642010    $embed_code = "";
     2011   
     2012    $youtube_id = oer_get_youtube_id($url);
     2013   
     2014    //Generate embed code
     2015    if ($youtube_id) {
     2016        $embed_code = '<div class="videoWrapper"><iframe width="640" height="360" src="https://www.youtube.com/embed/'.$youtube_id.'?rel=0" frameborder="0" allowfullscreen></iframe></div>';
     2017    }
     2018    return $embed_code;
     2019}
     2020
     2021function oer_get_youtube_id($url) {
     2022    $youtube_id = null;
     2023   
    19652024    if (preg_match('/youtube\.com\/watch\?v=([^\&\?\/]+)/', $url, $id)) {
    19662025        $youtube_id = $id[1];
     
    19752034    }
    19762035   
    1977     //Generate embed code
    1978     if ($youtube_id) {
    1979         $embed_code = '<div class="videoWrapper"><iframe width="640" height="360" src="https://www.youtube.com/embed/'.$youtube_id.'?rel=0" frameborder="0" allowfullscreen></iframe></div>';
    1980     }
    1981     return $embed_code;
     2036    return $youtube_id;
     2037}
     2038
     2039// Get Youtube Thumbnail
     2040function oer_get_youtube_thumbnail($youtube_url){
     2041    $youtube_id = oer_get_youtube_id($youtube_url);
     2042   
     2043    $thumbnail_url = "https://i.ytimg.com/vi/".$youtube_id."/hqdefault.jpg";
     2044   
     2045    $thumbnail_file = oer_save_image_to_file($thumbnail_url);
     2046   
     2047    return $thumbnail_file;
     2048}
     2049
     2050// Get Subject Areas
     2051function oer_get_subject_areas($resource_id){
     2052    // Resource Subject Areas
     2053    $subject_areas = array();
     2054    $post_terms = get_the_terms( $resource_id, 'resource-subject-area' );
     2055
     2056    if(!empty($post_terms))
     2057    {
     2058        foreach($post_terms as $term)
     2059        {
     2060            if($term->parent != 0)
     2061            {
     2062                $parent[] = oer_get_parent_term($term->term_id);
     2063            }
     2064            else
     2065            {
     2066                $subject_areas[] = $term;
     2067            }
     2068        }
     2069   
     2070        if(!empty($parent) && array_filter($parent))
     2071        {
     2072            $recur_multi_dimen_arr_obj =  new RecursiveArrayIterator($parent);
     2073            $recur_flat_arr_obj =  new RecursiveIteratorIterator($recur_multi_dimen_arr_obj);
     2074            $flat_arr = iterator_to_array($recur_flat_arr_obj, false);
     2075   
     2076            $flat_arr = array_values(array_unique($flat_arr));
     2077           
     2078            for($k=0; $k < count($flat_arr); $k++)
     2079            {
     2080                //$idObj = get_category_by_slug($flat_arr[$k]);
     2081                $idObj = get_term_by( 'slug' , $flat_arr[$k] , 'resource-subject-area' );
     2082               
     2083                if(!empty($idObj->name))
     2084                    $subject_areas[] = $idObj;
     2085            }
     2086        }
     2087    }
     2088    return $subject_areas;
    19822089}
    19832090
  • wp-oer/trunk/includes/resource_metafields.php

    r1714161 r1776251  
    116116                <?php $oer_lrtype = strtolower(get_post_meta($post->ID, 'oer_lrtype', true)); ?>
    117117                <select name="oer_lrtype">
     118            <option value=""></option>
    118119                       <option value="website" <?php if($oer_lrtype == 'website'){echo 'selected="selected"';}?>><?php _e("Assessment", OER_SLUG); ?></option>
    119120                       <option value="audio" <?php if($oer_lrtype == 'audio'){echo 'selected="selected"';}?>><?php _e("Audio", OER_SLUG); ?></option>
     
    138139                <?php $oer_interactivity = strtolower(get_post_meta($post->ID, 'oer_interactivity', true)); ?>
    139140                <select name="oer_interactivity">
     141            <option value=""></option>
    140142                       <option value="interactive" <?php if($oer_interactivity == 'interactive'){echo 'selected="selected"';}?>><?php _e("Interactive", OER_SLUG); ?></option>
    141143                       <option value="passive" <?php if($oer_interactivity == 'passive'){echo 'selected="selected"';}?>><?php _e("Passive", OER_SLUG); ?></option>
  • wp-oer/trunk/js/resource-category.js

    r1714161 r1776251  
    5252      jQuery('.sort-options').fadeToggle('fast');
    5353    });
     54    jQuery('.sort-resources').keydown(function(e){
     55    if (e.which==13 || e.which==32) {
     56        jQuery('.sort-options').fadeToggle('fast');
     57    }
     58    });
    5459   
    5560    jQuery('.sort-options ul li a').click(function(){
  • wp-oer/trunk/oer_template/resource-subject-area.php

    r1729969 r1776251  
    292292                    $title =  $post->post_title;
    293293                    //$content =  $post->post_content;
     294                    $highlight_content = strip_tags($post->post_content);
     295                   
    294296                    $offset = 0;
    295297                    $ellipsis = "...";
    296                     if (strlen($post->post_content)>150) {
    297                         $offset = strpos($post->post_content, ' ', 150);
     298                    if (strlen($highlight_content)>150) {
     299                        $offset = strpos($highlight_content, ' ', 150);
    298300                    } else
    299301                        $ellipsis = "";
     
    301303                    $length = 150;
    302304                   
    303                     $content =  trim(substr($post->post_content,0,$length)).$ellipsis;
     305                    $content =  trim(substr($highlight_content,0,$length)).$ellipsis;
    304306                ?>
    305307                    <li data-id="<?php echo $post->ID; ?>">
     
    314316                            <a href="<?php echo esc_url(get_permalink($post->ID));?>"><div class="img"><img src="<?php echo esc_url($new_image_url);?>" alt="<?php echo esc_attr($title);?>"></div></a>
    315317                            <div class="ttl"><a href="<?php echo esc_url(get_permalink($post->ID));?>"><?php echo $title;?></a></div>
    316                             <div class="desc"><?php echo apply_filters('the_content',$content); ?></div>
     318                            <div class="desc"><?php echo $content; ?></div>
    317319                        </div>
    318320                    <?php } ?>
     
    398400                       
    399401                        $title =  $post->post_title;
    400                         $content =  $post->post_content;
     402                        $content = strip_tags($post->post_content);
     403                       
    401404                        $ellipsis = "...";
    402405                        if (strlen($post->post_content)<180)
     
    429432                            }
    430433                        }
     434           
    431435                    ?>
    432436                        <div class="oer-snglrsrc">
     
    436440                            <div class="oer-snglttldscrght <?php if(empty($img_url)){ echo 'snglttldscrghtfull';}?>">
    437441                                <div class="ttl"><a href="<?php echo esc_url(get_permalink($post->ID));?>"><?php echo $title;?></a></div>
     442                            <?php
     443                                $subjects = array();
     444                                $grades = array();
     445                                //Display Meta of Resource
     446                                if ($post->post_type=="resource"){
     447                                    $ID = $post->ID;
     448                                    $url = get_post_meta($ID, "oer_resourceurl", true);
     449                                    $url_domain = oer_getDomainFromUrl($url);
     450                                    $grades =  trim(get_post_meta($ID, "oer_grade", true),",");
     451                                    ?>
     452                                    <div class="post-meta">
     453                                    <?php
     454                                    if ($grades) {
     455                                        $grades = explode(",",$grades);
     456                                        if(is_array($grades) && !empty($grades) && array_filter($grades)){
     457                                            $grade_label = "Grade: ";
     458                                            if (count($grades)>1)
     459                                                $grade_label = "Grades: ";
     460                                           
     461                                            echo "<span class='post-meta-box post-meta-grades'><strong>".$grade_label."</strong>";
     462                                           
     463                                            sort($grades);
     464                   
     465                                            for($x=0; $x < count($grades); $x++)
     466                                            {
     467                                              $grades[$x];
     468                                            }
     469                                            $fltrarr = array_filter($grades, 'strlen');
     470                                            $flag = array();
     471                                            $elmnt = $fltrarr[min(array_keys($fltrarr))];
     472                                            for($i =0; $i < count($fltrarr); $i++)
     473                                            {
     474                                                if($elmnt == $fltrarr[$i] || "k" == strtolower($fltrarr[$i]))
     475                                                {
     476                                                    $flag[] = 1;
     477                                                }
     478                                                else
     479                                                {
     480                                                    $flag[] = 0;
     481                                                }
     482                                                $elmnt++;
     483                                            }
     484                   
     485                                            if(in_array('0',$flag))
     486                                            {
     487                                                echo implode(",",array_unique($fltrarr));
     488                                            }
     489                                            else
     490                                            {
     491                                                $arr_flt = array_keys($fltrarr);
     492                                                $end_filter = end($arr_flt);
     493                                                if (count($fltrarr)>1) {
     494                                                    if (strtolower($fltrarr[$end_filter])=="k") {
     495                                                        $last_index = count($fltrarr)-2;
     496                                                        echo $fltrarr[$end_filter]."-".$fltrarr[$last_index];
     497                                                    }
     498                                                    else
     499                                                        echo $fltrarr[0]."-".$fltrarr[$end_filter];
     500                                                }
     501                                                else
     502                                                    echo $fltrarr[0];
     503                                            }
     504                                            echo "</span>";
     505                                        }
     506                                    }
     507                                    if ($url_domain) {
     508                                        ?>
     509                                        <span class="post-meta-box post-meta-domain"><strong>Domain: </strong><a href="<?php echo esc_url(get_post_meta($ID, "oer_resourceurl", true)); ?>" target="_blank" >
     510                                        <?php echo $url_domain; ?>
     511                                        </a></span>
     512                                        <?php
     513                                    }
     514                                    ?>
     515                                    </div>
     516                                    <?php
     517                                    $subjects = oer_get_subject_areas($ID);
     518                                }
     519                                ?>
    438520                                <div class="desc"><?php echo $content; ?></div>
     521                                <?php
     522                                // Display subject areas
     523                                if ($subjects) {
     524                                    $oer_subjects = array_unique($subjects, SORT_REGULAR);
     525                       
     526                                    if(!empty($oer_subjects))
     527                                    {
     528                                        ?>
     529                                        <div class="tagcloud">
     530                                        <?php
     531                                        foreach($oer_subjects as $subject)
     532                                        {
     533                                            echo '<span><a href="'.esc_url(site_url().'/'.$subject->taxonomy.'/'.$subject->slug).'" class="button">'.ucwords ($subject->name).'</a></span>';
     534                                        }
     535                                        ?>
     536                                        </div>
     537                                        <?php
     538                                    }
     539                                }
     540                                ?>
    439541                            </div>
    440542                        </div>
  • wp-oer/trunk/oer_template/single-resource.php

    r1729969 r1776251  
    7979                <!--Resource Image-->
    8080                <div class="oer-sngl-rsrc-img">
    81                     <a class="oer-featureimg" href="<?php echo esc_url(get_post_meta($post->ID, "oer_resourceurl", true)) ?>" target="_blank" >
    8281            <?php if ($youtube) {
    8382                $embed = oer_generate_youtube_embed_code($url);
    8483                echo $embed;
    8584             } else { ?>
     85             <a class="oer-featureimg" href="<?php echo esc_url(get_post_meta($post->ID, "oer_resourceurl", true)) ?>" target="_blank" >
    8686                <?php
    8787                    $img_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) , "full" );
     
    106106                    </a>
    107107            <?php } ?>
    108                     <a class="oer-rsrcurl" href="<?php echo esc_url(get_post_meta($post->ID, "oer_resourceurl", true)); ?>" target="_blank" >
    109                         <?php echo $url_domain; ?>
    110                     </a>
    111108                </div>
    112109            </div>
     
    134131                    <?php echo $content = apply_filters ("the_content", $post->post_content); ?>
    135132                </div>
     133            <?php } ?>
     134           
     135            <?php if ($youtube) { ?>
     136                <div class="oer-rsrcurl oer-cbxl"><h4><strong>Original Resource:</strong> <a href="<?php echo esc_url(get_post_meta($post->ID, "oer_resourceurl", true)); ?>" target="_blank" ><?php echo esc_url(get_post_meta($post->ID, "oer_resourceurl", true)); ?></a></h4></div>
     137            <?php } else { ?>
     138                <div class="oer-rsrcurl oer-cbxl"><h4><strong>Original Resource:</strong> <a href="<?php echo esc_url(get_post_meta($post->ID, "oer_resourceurl", true)); ?>" target="_blank" ><?php echo $url_domain; ?></a></h4></div>
    136139            <?php } ?>
    137140
  • wp-oer/trunk/open-educational-resources.php

    r1729969 r1776251  
    756756    global $_w_bootstrap;
    757757
    758     if (isset($_REQUEST['post_type']) && $_REQUEST['post_type']=="resource"){
     758    if ((isset($_REQUEST['post_type']) && $_REQUEST['post_type']=="resource") && (isset($_REQUEST['page']) && $_REQUEST['page']=="oer_settings")){
    759759        if (oer_is_bootstrap_loaded())
    760760            $_w_bootstrap = true;
     
    19491949        return $distinct;
    19501950}
     1951
     1952/** Include Post Type Tag **/
     1953function oer_resource_taxonomy_queries( $query ) {
     1954    if ( $query->is_tag() && $query->is_main_query() ) {
     1955            $query->set( 'post_type', array( 'post', 'resource' ) );
     1956    }
     1957}
     1958add_action( 'pre_get_posts', 'oer_resource_taxonomy_queries' );
     1959
     1960function oer_custom_search_template($template){
     1961    global $wp_query;
     1962    if (!$wp_query->is_search)
     1963        return $template;
     1964   
     1965    $current_theme = wp_get_theme();
     1966   
     1967    if ($current_theme=="Avada")
     1968        return OER_PATH . 'oer_template/avada-search.php';
     1969    else
     1970        return OER_PATH . 'oer_template/search.php';
     1971}
     1972add_filter('template_include','oer_custom_search_template');
    19511973?>
  • wp-oer/trunk/readme.txt

    r1729969 r1776251  
    33Tags: OER, Open Educational Resources, Education, Learning
    44Requires at least: WordPress. 4.4
    5 Tested up to: WordPress 4.8
    6 Stable tag: 0.5.8
     5Tested up to: WordPress 4.9
     6Stable tag: 0.5.9
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4242== Changelog ==
    4343
     44= 0.5.9 =
     45* Make Youtube video display responsive
     46* Get Youtube thumbnail image and use as featured image for youtube resource
     47* Add original resource link below resource description
     48* Add metadata such as grade and domain to resources in search result
     49* Fix broken resource tag links
     50* Fix bug showing nonce error when deleting resource
     51* Trim search result and subject area resource description to 3 lines with ellipsis using pure css
     52
    4453= 0.5.8 =
    4554* Display YouTube resources as video embeds
Note: See TracChangeset for help on using the changeset viewer.