WordPressにTwenty Fifteenの子テーマを作って適用してみた

WordPressにTwenty Fifteenの子テーマを適用してみました
以前はTwenty Elevenの子テーマをつくっていたので、今回も子テーマを用意します

普通にWordpressをアップデートしてけば、Twenty Fifteenがあるのでインストールは終わっています

以前は

WordPressにシェアボタンを用意する過程を公開 | bgbgbg
WordPressの子テーマ用にPHPを変更する | bgbgbg

な感じで用意したので、手順はほぼ同じです

子テーマ – WordPress Codex 日本語版
を見ながら、子テーマを用意します

WordPressのインストールディレクトリへ移動して

mkdir wp-content/themes/twentyfifteen-child
touch wp-content/themes/twentyfifteen-child/style.css
touch wp-content/themes/twentyfifteen-child/function.php

style.cssの記載をします(最低限)

/*
Theme Name: Twenty Fifteen child
Template: twentyfifteen 
*/

cssはfunction.phpで読み込むようになりました

<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}       

add_action( 'wp_enqueue_scripts', 'theme_enqueue_fontawesome' );
function theme_enqueue_fontawesome() {
    wp_enqueue_style( 'parent-style', '//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css');
}                      

そしたらボタンを画面に出すのに、今回はcontent.phpにしました
子テーマへコピー

cp wp-content/themes/twentyfifteen/content.php wp-content/themes/twentyfifteen-child/content.php

で追記

/* 省略 */
        <div class="entry-content">
                /* 省略 */

                <!-- refference: http://tsuchiyashutaro.com/archives/2992 -->
                <ul class="share_btn">
                <li>
                <a class="facebook_btn"
                href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false;">
                <i class="fa fa-facebook social_icon"></i>share</a>
                </li>
                <li><a class="twitter_btn" href="http://twitter.com/share?text=<?php the_title(); ?>&url=<?php the_permalink(); ?>" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false;">
                <i class="fa fa-twitter social_icon"></i>tweet</a>
                </li>
                <li><a class="hatebu_btn" href="http://b.hatena.ne.jp/add?mode=confirm&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false;"><i class="fa fa-hatena social_icon"></i><span class="hatebu_chara">はてブ<span></a></li>
                </ul>
                <!-- refference end -->
        </div><!-- .entry-content -->
/* 省略 */

でできあがりです

Apacheでwwwありのアクセスをなしに転送する

ウェブサーバーで、wwwありのドメインとなしのドメインではGoogleで別評価されるようなので
Apacheの.htaccessで301リダイレクトしてみました

公開しているWebディレクトリの転送したい場所で、.htaccessを設置して

RewriteCond %{HTTP_HOST} ^www.sample.jp [NC]
RewriteRule ^(.*)$ http://sample.jp/$1 [R=301,L]                                                   

こんな感じです

Virtualboxをアップデートしたらエラー発生

DKMSをいれたらとのことなので入れてみる

$ sudo apt-get install dkms

が入ってました

指示通りコマンド実行

$ sudo /etc/init.d/vboxdrv setup

Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modulesError! Could not locate dkms.conf file.
File:  does not exist.
 ...done.
Removing old VirtualBox pci kernel module ...done.
Removing old VirtualBox netadp kernel module ...done.
Removing old VirtualBox netflt kernel module ...done.
Removing old VirtualBox kernel module ...done.
Trying to register the VirtualBox kernel modules using DKMSError! DKMS tree already contains: vboxhost-4.3.26
You cannot add the same module/version combo more than once.
 ...failed!
  (Failed, trying without DKMS)
Recompiling VirtualBox kernel modules ...done.
Starting VirtualBox kernel modules ...done.

なんだかFailedって出てるけど、Virtualboxが動くようになりました

rakeでタスクの一覧を見る

Spreeのときはデフォルトの管理ユーザーを作るのに

$ rake spree_auth:admin:create

を使ったりします
参考: Ruby on RailsにSpreeを入れてみた | bgbgbg

こういったタスクなにがあるんだっけ..?のときに

$ rake -T

とすると一覧で見れて便利です

ちなみに spree を入れた時の結果はこんな感じ

rake assets:clobber                                 # Remove compiled assets
rake assets:environment                             # Load asset compile environment
rake assets:precompile                              # Compile all the assets named in config.assets.precompile
rake cache_digests:dependencies                     # Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_comment.html)
rake cache_digests:nested_dependencies              # Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)
rake db:bootstrap                                   # Bootstrap is: migrating, loading defaults, sample data and seeding (for all extensions) and load_products tasks
rake db:create                                      # Creates the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:create:all to create all databases in the config)
rake db:drop                                        # Drops the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:drop:all to drop all databases in the config)
rake db:fixtures:load                               # Load fixtures into the current environment's database
rake db:load_dir[dir]                               # Loads fixtures from the the dir you specify using rake db:load_dir[loadfrom]
rake db:load_file[file,dir]                         # Loads a specified fixture file:
rake db:migrate                                     # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
rake db:migrate:status                              # Display status of migrations
rake db:remigrate                                   # Migrate schema to version 0 and back up again
rake db:rollback                                    # Rolls the schema back to the previous version (specify steps w/ STEP=n)
rake db:schema:cache:clear                          # Clear a db/schema_cache.dump file
rake db:schema:cache:dump                           # Create a db/schema_cache.dump file
rake db:schema:dump                                 # Create a db/schema.rb file that is portable against any DB supported by AR
rake db:schema:load                                 # Load a schema.rb file into the database
rake db:seed                                        # Load the seed data from db/seeds.rb
rake db:setup                                       # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the database first)
rake db:structure:dump                              # Dump the database structure to db/structure.sql
rake db:structure:load                              # Recreate the databases from the structure.sql file
rake db:version                                     # Retrieves the current schema version number
rake deface:clean                                   # Removes all precompiled override templates
rake deface:failures_by_virtual_path[virtual_path]  # Report on failing overrides for a partial/template
rake deface:get_result[virtual_path]                # Get the resulting markup for a partial/template
rake deface:precompile                              # Precompiles overrides into template files
rake deface:test_all                                # Load and apply all overrides, and output results
rake deface:test_selector[virtual_path,selector]    # Applies selectors to given partial/template, and returns match(s) source
rake doc:app                                        # Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE="Custom Title")
rake email:test                                     # Sends test email to specified address - Example: EMAIL=spree@example.com bundle exec rake test:email
rake exchanges:charge_unreturned_items              # Takes unreturned exchanged items and creates a new order to charge
rake log:clear                                      # Truncates all *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)
rake middleware                                     # Prints out your Rack middleware stack
rake notes                                          # Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)
rake notes:custom                                   # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM
rake paperclip:clean                                # Cleans out invalid attachments
rake paperclip:refresh                              # Refreshes both metadata and thumbnails
rake paperclip:refresh:metadata                     # Regenerates content_type/size metadata for a given CLASS (and optional ATTACHMENT)
rake paperclip:refresh:missing_styles               # Regenerates missing thumbnail styles for all classes using Paperclip
rake paperclip:refresh:thumbnails                   # Regenerates thumbnails for a given CLASS (and optional ATTACHMENT and STYLES splitted by comma)
rake rails:template                                 # Applies the template supplied by LOCATION=(/path/to/template) or URL
rake rails:update                                   # Update configs and some other initially generated files (or use just update:configs or update:bin)
rake routes                                         # Print out all defined routes in match order, with names
rake secret                                         # Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)
rake spec                                           # Run all specs in spec directory (excluding plugin specs)
rake spec:controllers                               # Run the code examples in spec/controllers
rake spec:helpers                                   # Run the code examples in spec/helpers
rake spree:install:migrations                       # Copy migrations from spree to application
rake spree:reset_taxon_permalinks                   # Resets all taxon permalinks
rake spree_api:install:migrations                   # Copy migrations from spree_api to application
rake spree_auth:admin:create                        # Create admin username and password
rake spree_auth:install:migrations                  # Copy migrations from spree_auth to application
rake spree_i18n:install:migrations                  # Copy migrations from spree_i18n to application
rake spree_paypal_express:install:migrations        # Copy migrations from spree_paypal_express to application
rake spree_sample:load                              # Loads sample data
rake stats                                          # Report code statistics (KLOCs, etc) from the application or engine
rake test                                           # Runs all tests in test folder
rake test:all                                       # Run tests quickly by merging all types and not resetting db
rake test:all:db                                    # Run tests quickly, but also reset db
rake test:db                                        # Run tests quickly, but also reset db
rake time:zones:all                                 # Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6
rake tmp:clear                                      # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)
rake tmp:create                                     # Creates tmp directories for sessions, cache, sockets, and pids