Class: WPMove::Main
- Inherits:
-
Object
- Object
- WPMove::Main
- Defined in:
- lib/wp-move.rb
Class Method Summary collapse
Class Method Details
.exec_php(blob) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/wp-move.rb', line 45 def self.exec_php(blob) f = File.open('_from_ruby.php', 'w') f.write("<?php ") f.write("require 'wp-load.php';") f.write(blob) f.write('?>') f.write('') f.close result = `php _from_ruby.php` FileUtils.rm_f '_from_ruby.php' return result end |
.rename(name) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wp-move.rb', line 26 def self.rename(name) php = """ global $wpdb; $oldurl = get_option('siteurl'); $newurl = '#{name}'; $wpdb->query(\"UPDATE \".$wpdb->prefix.\"options SET option_value = replace(option_value, '\".$oldurl.\"', '\".$newurl.\"') WHERE option_name = 'home' OR option_name = 'siteurl'\"); $wpdb->query(\"UPDATE \".$wpdb->prefix.\"posts SET guid = replace(guid, '\".$oldurl.\"', '\".$newurl.\"')\"); $wpdb->query(\"UPDATE \".$wpdb->prefix.\"posts SET post_content = replace(post_content, '\".$oldurl.\"', '\".$newurl.\"')\"); """ self.exec_php(php) puts "Renamed to: #{name}" end |
.test ⇒ Object
22 23 24 |
# File 'lib/wp-move.rb', line 22 def self.test # test if WP installation end |
.wp_current_url ⇒ Object
41 42 43 |
# File 'lib/wp-move.rb', line 41 def self.wp_current_url Tools.exec_php("bloginfo('siteurl');") end |