Module: WpWrapper::Modules::Plugins
- Includes:
- Akismet, Gocodes, TrackingCode, W3TotalCache, WordpressSeo
- Included in:
- Client
- Defined in:
- lib/wp_wrapper/modules/plugins.rb,
lib/wp_wrapper/modules/plugins/akismet.rb,
lib/wp_wrapper/modules/plugins/gocodes.rb,
lib/wp_wrapper/modules/plugins/tracking_code.rb,
lib/wp_wrapper/modules/plugins/wordpress_seo.rb,
lib/wp_wrapper/modules/plugins/w3_total_cache.rb
Defined Under Namespace
Modules: Akismet, Gocodes, TrackingCode, W3TotalCache, WordpressSeo
Instance Method Summary collapse
- #manage_plugin(plugin_identifier, action = :activate) ⇒ Object
- #manage_plugins(plugin_identifiers, action = :activate) ⇒ Object
Methods included from TrackingCode
Methods included from WordpressSeo
#configure_wordpress_seo, #configure_wordpress_seo_sitemaps, #get_author_options, #get_taxonomy_options, #get_title_options, #translate_pattern
Methods included from W3TotalCache
#activate_configuration, #configure_browser_cache, #configure_general_settings, #configure_minification, #configure_page_cache, #configure_w3_total_cache
Methods included from Gocodes
Methods included from Akismet
Instance Method Details
#manage_plugin(plugin_identifier, action = :activate) ⇒ Object
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 |
# File 'lib/wp_wrapper/modules/plugins.rb', line 18 def manage_plugin(plugin_identifier, action = :activate) success = false if (login) activation_link = nil plugins_page = self.mechanize_client.open_url(get_url(:plugins)) if (plugins_page) plugin_links = plugins_page.parser.css("table.plugins tbody tr td span.#{action} a") regex = Regexp.new("plugin=#{plugin_identifier}", Regexp::IGNORECASE) plugin_links.each do |link| href = link["href"] if (regex.match(href)) activation_link = href break end end if (plugin_links && plugin_links.any?) if (activation_link && activation_link.present?) url = "#{get_url(:admin)}/#{activation_link}" self.mechanize_client.open_url(url) puts "#{Time.now}: Url: #{self.url}. Plugin '#{plugin_identifier}' has been #{action}d!" success = true else puts "#{Time.now}: Url: #{self.url}. Couldn't find the plugin #{plugin_identifier}'s #{action}-link." end end else puts "#{Time.now}: Failed to login for url #{self.url}, will not proceed to #{action} plugins" end return success end |
#manage_plugins(plugin_identifiers, action = :activate) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/wp_wrapper/modules/plugins.rb', line 10 def manage_plugins(plugin_identifiers, action = :activate) plugin_identifiers = (plugin_identifiers.is_a?(Array)) ? plugin_identifiers : [plugin_identifiers.to_s] plugin_identifiers.each do |plugin_identifier| manage_plugin(plugin_identifier, action) end end |