##A Playlist for Learning Design
Compilation by mariusz.cc
I re-hosted his compilation because his site is down.
###Design process
| <?php | |
| if ( !function_exists( 'get_option_tree') ) { | |
| echo '<h1>OptionTree Is Required for this theme</h1> | |
| Download it here: LINK'; | |
| } | |
| ?> |
| <!-- I needed to limit the words in the WordPress search query to display it as a title and a long query broke the whole thing, so this did the trick --> | |
| <?php | |
| $my_search_query = get_search_query(); | |
| echo string_limit_words($my_search_query, 3); | |
| ?>[...] |
| if ( !class_exists( 'HijackMe' ) ) { | |
| class HijackMe { | |
| public function hijack_menu($objects) { | |
| /** | |
| * If user isn't logged in, we return the link as normal | |
| */ | |
| if ( !is_user_logged_in() ) { | |
| return $objects; | |
| } | |
| /** |
| 'use strict'; | |
| /**************************************** | |
| * Chapter 3 Exercises: Functions | |
| ***************************************** | |
| #EXERCISE 1: Minimum | |
| The previous chapter introduced the standard function Math.min that returns | |
| its smallest argument. We can do that ourselves now. Write a function min that |
##A Playlist for Learning Design
Compilation by mariusz.cc
I re-hosted his compilation because his site is down.
###Design process
| class ArrayModifier | |
| attr_accessor :array | |
| def initialize(array) | |
| @array = array | |
| end | |
| def exclaim | |
| new_array = [] |
| def add_value_and_index(arr) | |
| arr.each_with_index do |e, i| | |
| arr[i] += i | |
| end | |
| end | |
| a = add_value_and_index([2,1,0]) | |
| p a | |
| # → [2, 2, 2] |
| class Title | |
| attr_reader :str | |
| def initialize(str) | |
| @str = str | |
| end | |
| def fix |
| class User | |
| attr_accessor :name, :email, :bio, :age, :sex | |
| def initialize(config = {}) | |
| @name = config[:name] || "n/a" | |
| @email = config[:email] || "n/a" | |
| @bio = config[:bio] || "n/a" | |
| @age = config[:age] || "n/a" | |
| @sex = config[:sex] || "n/a" | |
| end |
| def hash_to_array(hash = {}) | |
| ary = [] | |
| hash.each do |k, v| | |
| ary << "#{k} is #{v}" | |
| end | |
| ary | |
| end | |
| hash_to_array({name: "Ivor"}) |