Module: Wpxf::WordPress::Comments
- Includes:
- Wpxf
- Defined in:
- lib/wpxf/wordpress/comments.rb
Overview
Provides functionality for gathering and posting comments.
Instance Method Summary collapse
-
#initialize ⇒ Object
Initialises a new instance of Comments.
-
#post_wordpress_comment(post_id, content, author, email, website) ⇒ Integer
Post a comment.
-
#should_register_comment_posting_options ⇒ Boolean
A value indicating whether or not to register the options required to post a WordPress comment.
Instance Method Details
#initialize ⇒ Object
Initialises a new instance of Wpxf::WordPress::Comments
8 9 10 11 12 |
# File 'lib/wpxf/wordpress/comments.rb', line 8 def initialize super if end |
#post_wordpress_comment(post_id, content, author, email, website) ⇒ Integer
Post a comment.
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 |
# File 'lib/wpxf/wordpress/comments.rb', line 27 def post_wordpress_comment(post_id, content, , email, website) comment_id = -1 scoped_option_change('follow_http_redirection', false) do res = execute_post_request( url: wordpress_url_comments_post, cookie: , body: { author: , comment: content, email: email, url: website, submit: 'Post Comment', comment_post_ID: post_id, comment_parent: 0 } ) if res&.code == 302 id = res.headers['Location'][/#comment-([0-9]+)/i, 1] comment_id = id.to_i if id end end comment_id end |
#should_register_comment_posting_options ⇒ Boolean
Returns a value indicating whether or not to register the options required to post a WordPress comment.
16 17 18 |
# File 'lib/wpxf/wordpress/comments.rb', line 16 def true end |