Class: Shellpress::Post

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/shellpress/post.rb

Constant Summary collapse

ORDER =
2

Instance Method Summary collapse

Methods inherited from Thor

banner, #help

Instance Method Details

#delete(id) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/shellpress/post.rb', line 10

def delete(id)
  force = options[:force]
  type = options[:type]

  php = "<?php include 'wp-load.php';"

  if id =~ /\d+/
    php << "wp_delete_post(#{id}, #{force});"
  else
    php << "$post = get_page_by_path('#{id}', OBJECT, '#{type}');"
    php << "if ($post) wp_delete_post($post->ID, #{force});"
  end

  php << "?>"

  File.open("temp.php", "w") {|f| f.write(php)}
  run "php -q temp.php"
  remove_file "temp.php", :verbose => false

end