Module: WpWrapper::Modules::Plugins::W3TotalCache
- Included in:
- WpWrapper::Modules::Plugins
- Defined in:
- lib/wp_wrapper/modules/plugins/w3_total_cache.rb
Instance Method Summary collapse
- #activate_configuration ⇒ Object
- #configure_browser_cache ⇒ Object
- #configure_general_settings(caching_mechanism, options = {}) ⇒ Object
- #configure_minification(options = {}) ⇒ Object
- #configure_page_cache ⇒ Object
- #configure_w3_total_cache(caching_mechanism = :memcached, options = {}) ⇒ Object
Instance Method Details
#activate_configuration ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/wp_wrapper/modules/plugins/w3_total_cache.rb', line 116 def activate_configuration url = "#{get_url(:admin)}admin.php?page=w3tc_general" page = self.mechanize_client.get_page(url) parser = page ? self.mechanize_client.get_parser(page) : nil input = parser ? parser.at_css('input[value = "deploy"]') : nil if (input) on_click = input["onclick"] url = on_click.gsub("admin.php?page=w3tc_general", url) url = url.gsub(/^document\.location\.href='/i, "").gsub(/';$/, "") puts "Will activate new W3 Total Cache-configuration. Activation url: #{url}" self.http_client.retrieve_raw_content(url) end end |
#configure_browser_cache ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/wp_wrapper/modules/plugins/w3_total_cache.rb', line 92 def configure_browser_cache = {} url = "admin.php?page=w3tc_browsercache" form_identifier = {:action => /admin\.php\?page=w3tc_browsercache/i, :index => 1} = {:name => 'w3tc_default_save_and_flush'} sections = [ :cssjs, :html, :other ] sections.each do |section| = { "browsercache__#{section}__expires" => {:checked => true, :type => :checkbox}, "browsercache__#{section}__cache__control" => {:checked => true, :type => :checkbox}, "browsercache__#{section}__etag" => {:checked => true, :type => :checkbox}, } .merge!() end return (url, form_identifier, ) end |
#configure_general_settings(caching_mechanism, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/wp_wrapper/modules/plugins/w3_total_cache.rb', line 14 def configure_general_settings(caching_mechanism, = {}) = {} cache_sections = [:pg, :db, :object] url = "admin.php?page=w3tc_general" form_identifier = {:id => 'w3tc_form'} = {:name => 'w3tc_default_save_and_flush'} varnish_server = .fetch(:varnish_server, "localhost") cache_sections.each do |cache_section| = { "#{cache_section}cache__enabled" => {:checked => true, :type => :checkbox}, "#{cache_section}cache__engine" => {:value => caching_mechanism, :type => :select} } .merge!() end = { "minify__enabled" => {:checked => true, :type => :checkbox}, "minify__engine" => {:value => caching_mechanism, :type => :select}, } .merge!() = { "browsercache__enabled" => {:checked => true, :type => :checkbox}, } .merge!() = { "varnish__enabled" => {:checked => true, :type => :checkbox}, "varnish__servers" => {:value => varnish_server, :type => :input} } .merge!() return (url, form_identifier, , ) end |
#configure_minification(options = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/wp_wrapper/modules/plugins/w3_total_cache.rb', line 68 def configure_minification( = {}) url = "admin.php?page=w3tc_minify" form_identifier = {:action => /admin\.php\?page=w3tc_minify/i, :index => 1} = {:name => 'w3tc_default_save_and_flush'} minify_html = .fetch(:html, :enable).to_sym.eql?(:enable) minify_inline_css = .fetch(:inline_css, :enable).to_sym.eql?(:enable) minify_inline_js = .fetch(:inline_js, :enable).to_sym.eql?(:enable) minify_js = .fetch(:js, :disable).to_sym.eql?(:enable) minify_css = .fetch(:css, :disable).to_sym.eql?(:enable) = { "minify__html__enable" => {:checked => minify_html, :type => :checkbox}, "minify__html__inline__css" => {:checked => minify_inline_css, :type => :checkbox}, "minify__html__inline__js" => {:checked => minify_inline_js, :type => :checkbox}, "minify__js__enable" => {:checked => minify_js, :type => :checkbox}, "minify__css__enable" => {:checked => minify_css, :type => :checkbox}, } return (url, form_identifier, , ) end |
#configure_page_cache ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/wp_wrapper/modules/plugins/w3_total_cache.rb', line 56 def configure_page_cache url = "admin.php?page=w3tc_pgcache" form_identifier = {:action => /admin\.php\?page=w3tc_pgcache/i, :index => 1} = {:name => 'w3tc_default_save_and_flush'} = { "pgcache__cache__feed" => {:checked => true, :type => :checkbox}, } return (url, form_identifier, , ) end |
#configure_w3_total_cache(caching_mechanism = :memcached, options = {}) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/wp_wrapper/modules/plugins/w3_total_cache.rb', line 6 def configure_w3_total_cache(caching_mechanism = :memcached, = {}) configure_general_settings(caching_mechanism, ) configure_page_cache configure_minification(.fetch(:minify, {})) configure_browser_cache activate_configuration end |