Changeset 1776251
- Timestamp:
- 11/27/2017 03:33:08 PM (8 years ago)
- Location:
- wp-oer/trunk
- Files:
-
- 10 edited
-
css/front_styles.css (modified) (1 diff)
-
css/resource-style.css (modified) (1 diff)
-
includes/init.php (modified) (3 diffs)
-
includes/oer-functions.php (modified) (6 diffs)
-
includes/resource_metafields.php (modified) (2 diffs)
-
js/resource-category.js (modified) (1 diff)
-
oer_template/resource-subject-area.php (modified) (6 diffs)
-
oer_template/single-resource.php (modified) (3 diffs)
-
open-educational-resources.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-oer/trunk/css/front_styles.css
r1714161 r1776251 411 411 .oer-rsrclftcntr-img { padding-left:0 !important; } 412 412 .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; } 414 444 @media screen and (max-width: 600px) { 415 445 .oer_blgpst .oer-feature-image { width:100%; float:none; margin-bottom:10px; } -
wp-oer/trunk/css/resource-style.css
r1729969 r1776251 59 59 height: 100%; 60 60 } 61 .oer-sngl-rsrc-img .oer-rsrcurl.left { text-align:left; } 61 62 /** For Mobile styles **/ 62 63 @media screen and (min-width: 960px) { -
wp-oer/trunk/includes/init.php
r1729969 r1776251 351 351 if($post->post_type == 'resource') 352 352 { 353 if (isset($_GET['action']) && ($_GET['action']=="trash" || $_GET['action']=="untrash")){ 354 return; 355 } 353 356 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'); 355 358 } 356 359 if(isset($_POST['oer_resourceurl'])) … … 581 584 { 582 585 $url = esc_url_raw($_POST['oer_resourceurl']); 586 587 $youtube = oer_is_youtube_url($url); 588 583 589 $upload_dir = wp_upload_dir(); 584 590 $file = ''; … … 593 599 if ( $external_screenshot ) 594 600 $file = oer_getImageFromExternalURL($url); 595 } 596 601 602 if ( $youtube ) 603 $file = oer_get_youtube_thumbnail($url); 604 } 605 597 606 if(file_exists($file)) 598 607 { -
wp-oer/trunk/includes/oer-functions.php
r1729969 r1776251 835 835 } 836 836 837 function 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 837 870 //Get External Thumbnail Image 838 871 function oer_getExternalThumbnailImage($url, $local=false) { … … 896 929 $url = get_site_url(); 897 930 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 899 936 $content = htmlentities($content); 900 937 … … 913 950 914 951 return $bootstrap; 952 } 953 954 /** Get resource via curl **/ 955 function 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; 915 962 } 916 963 … … 1647 1694 <div class="sort-box"> 1648 1695 <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> 1650 1697 <div class="sort-options"> 1651 1698 <ul> … … 1961 2008 //Generate youtube embed code 1962 2009 function oer_generate_youtube_embed_code($url) { 1963 $youtube_id = "";1964 2010 $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 2021 function oer_get_youtube_id($url) { 2022 $youtube_id = null; 2023 1965 2024 if (preg_match('/youtube\.com\/watch\?v=([^\&\?\/]+)/', $url, $id)) { 1966 2025 $youtube_id = $id[1]; … … 1975 2034 } 1976 2035 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 2040 function 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 2051 function 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; 1982 2089 } 1983 2090 -
wp-oer/trunk/includes/resource_metafields.php
r1714161 r1776251 116 116 <?php $oer_lrtype = strtolower(get_post_meta($post->ID, 'oer_lrtype', true)); ?> 117 117 <select name="oer_lrtype"> 118 <option value=""></option> 118 119 <option value="website" <?php if($oer_lrtype == 'website'){echo 'selected="selected"';}?>><?php _e("Assessment", OER_SLUG); ?></option> 119 120 <option value="audio" <?php if($oer_lrtype == 'audio'){echo 'selected="selected"';}?>><?php _e("Audio", OER_SLUG); ?></option> … … 138 139 <?php $oer_interactivity = strtolower(get_post_meta($post->ID, 'oer_interactivity', true)); ?> 139 140 <select name="oer_interactivity"> 141 <option value=""></option> 140 142 <option value="interactive" <?php if($oer_interactivity == 'interactive'){echo 'selected="selected"';}?>><?php _e("Interactive", OER_SLUG); ?></option> 141 143 <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 52 52 jQuery('.sort-options').fadeToggle('fast'); 53 53 }); 54 jQuery('.sort-resources').keydown(function(e){ 55 if (e.which==13 || e.which==32) { 56 jQuery('.sort-options').fadeToggle('fast'); 57 } 58 }); 54 59 55 60 jQuery('.sort-options ul li a').click(function(){ -
wp-oer/trunk/oer_template/resource-subject-area.php
r1729969 r1776251 292 292 $title = $post->post_title; 293 293 //$content = $post->post_content; 294 $highlight_content = strip_tags($post->post_content); 295 294 296 $offset = 0; 295 297 $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); 298 300 } else 299 301 $ellipsis = ""; … … 301 303 $length = 150; 302 304 303 $content = trim(substr($ post->post_content,0,$length)).$ellipsis;305 $content = trim(substr($highlight_content,0,$length)).$ellipsis; 304 306 ?> 305 307 <li data-id="<?php echo $post->ID; ?>"> … … 314 316 <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> 315 317 <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> 317 319 </div> 318 320 <?php } ?> … … 398 400 399 401 $title = $post->post_title; 400 $content = $post->post_content; 402 $content = strip_tags($post->post_content); 403 401 404 $ellipsis = "..."; 402 405 if (strlen($post->post_content)<180) … … 429 432 } 430 433 } 434 431 435 ?> 432 436 <div class="oer-snglrsrc"> … … 436 440 <div class="oer-snglttldscrght <?php if(empty($img_url)){ echo 'snglttldscrghtfull';}?>"> 437 441 <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 ?> 438 520 <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 ?> 439 541 </div> 440 542 </div> -
wp-oer/trunk/oer_template/single-resource.php
r1729969 r1776251 79 79 <!--Resource Image--> 80 80 <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" >82 81 <?php if ($youtube) { 83 82 $embed = oer_generate_youtube_embed_code($url); 84 83 echo $embed; 85 84 } else { ?> 85 <a class="oer-featureimg" href="<?php echo esc_url(get_post_meta($post->ID, "oer_resourceurl", true)) ?>" target="_blank" > 86 86 <?php 87 87 $img_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) , "full" ); … … 106 106 </a> 107 107 <?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>111 108 </div> 112 109 </div> … … 134 131 <?php echo $content = apply_filters ("the_content", $post->post_content); ?> 135 132 </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> 136 139 <?php } ?> 137 140 -
wp-oer/trunk/open-educational-resources.php
r1729969 r1776251 756 756 global $_w_bootstrap; 757 757 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")){ 759 759 if (oer_is_bootstrap_loaded()) 760 760 $_w_bootstrap = true; … … 1949 1949 return $distinct; 1950 1950 } 1951 1952 /** Include Post Type Tag **/ 1953 function oer_resource_taxonomy_queries( $query ) { 1954 if ( $query->is_tag() && $query->is_main_query() ) { 1955 $query->set( 'post_type', array( 'post', 'resource' ) ); 1956 } 1957 } 1958 add_action( 'pre_get_posts', 'oer_resource_taxonomy_queries' ); 1959 1960 function 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 } 1972 add_filter('template_include','oer_custom_search_template'); 1951 1973 ?> -
wp-oer/trunk/readme.txt
r1729969 r1776251 3 3 Tags: OER, Open Educational Resources, Education, Learning 4 4 Requires at least: WordPress. 4.4 5 Tested up to: WordPress 4. 86 Stable tag: 0.5. 85 Tested up to: WordPress 4.9 6 Stable tag: 0.5.9 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 42 42 == Changelog == 43 43 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 44 53 = 0.5.8 = 45 54 * Display YouTube resources as video embeds
Note: See TracChangeset
for help on using the changeset viewer.