Unverified Commit 7e59d961 authored by Martin Lees's avatar Martin Lees Committed by GitHub
Browse files

Merge pull request #14 from drov0/dev-update

Allow editing of steem posts directly from wordpress
parents e69d8711 ab5ed170
......@@ -389,17 +389,19 @@ class Steempress_sp_Admin {
{
// New post
if ($new_status == 'publish' && $old_status != 'publish' && $post->post_type == 'post') {
if (!isset($_POST['Steempress_sp_steem_publish']) && isset($_POST['Steempress_sp_steem_do_not_publish']) ) {
if (!isset($_POST['Steempress_sp_steem_publish']) && isset($_POST['Steempress_sp_steem_do_not_publish']) )
return;
} else {
$value = get_post_meta($post->ID, 'Steempress_sp_steem_publish', true);
if ($value != "0")
$this->Steempress_sp_publish($post->ID);
}
$value = get_post_meta($post->ID, 'Steempress_sp_steem_publish', true);
if ($value != "0")
$this->Steempress_sp_publish($post->ID);
// Edited post
} /*else if ($new_status == 'publish' && $old_status == 'publish' && $post->post_type == 'post') {
} else if ($new_status == 'publish' && $old_status == 'publish' && $post->post_type == 'post') {
if (!isset($_POST['Steempress_sp_steem_update']) && isset($_POST['Steempress_sp_steem_do_not_update']) )
return;
$this->steempress_sp_update($post->ID);
}*/
}
return;
}
......@@ -432,26 +434,55 @@ class Steempress_sp_Admin {
<?php
}
function saveSteemPublishField($post_id)
function create_update_checkbox()
{
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
$post_id = get_the_ID();
if (get_post_type($post_id) != 'post') {
return;
}
if (
!isset($_POST['Steempress_sp_custom_nonce']) ||
!wp_verify_nonce($_POST['Steempress_sp_custom_nonce'], 'Steempress_sp_custom_nonce_'.$post_id)
) {
if (get_post_status ($post_id) != 'publish')
return;
}
if (!current_user_can('edit_post', $post_id)) {
wp_nonce_field('Steempress_sp_custom_update_nonce_'.$post_id, 'Steempress_sp_custom_update_nonce');
$value = get_post_meta($post_id, 'Steempress_sp_steem_update', true);
if ($value == "0")
$checked = "";
else
$checked = "checked";
?>
<div class="misc-pub-section misc-pub-section-last">
<label><input type="checkbox" value="1" <?php echo $checked; ?> name="Steempress_sp_steem_update" /> <input type="hidden" name="Steempress_sp_steem_do_not_update" value="0" />Update to steem </label>
</div>
<?php
}
function saveSteemPublishField($post_id)
{
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return;
}
if (isset($_POST['Steempress_sp_steem_publish'])) {
update_post_meta($post_id, 'Steempress_sp_steem_publish', $_POST['Steempress_sp_steem_publish']);
if ((!isset($_POST['Steempress_sp_custom_nonce']) || !wp_verify_nonce($_POST['Steempress_sp_custom_nonce'], 'Steempress_sp_custom_nonce_'.$post_id)) && (!isset($_POST['Steempress_sp_custom_update_nonce']) || !wp_verify_nonce($_POST['Steempress_sp_custom_update_nonce'], 'Steempress_sp_custom_update_nonce_'.$post_id)))
return;
if (!current_user_can('edit_post', $post_id))
return;
if (get_post_status ($post_id) != 'publish') {
if (isset($_POST['Steempress_sp_steem_publish'])) {
update_post_meta($post_id, 'Steempress_sp_steem_publish', $_POST['Steempress_sp_steem_publish']);
} else {
update_post_meta($post_id, 'Steempress_sp_steem_publish', '0');
}
} else {
update_post_meta($post_id, 'Steempress_sp_steem_publish', '0');
if (isset($_POST['Steempress_sp_steem_update'])) {
update_post_meta($post_id, 'Steempress_sp_steem_update', $_POST['Steempress_sp_steem_update']);
} else {
update_post_meta($post_id, 'Steempress_sp_steem_update', '0');
}
}
}
......@@ -635,7 +666,6 @@ class Steempress_sp_Admin {
$test = $data['body'];
if ($test['tags'] != "" && $test['author'] != "" && $test['wif'] != "") {
// Post to the api who will update it on the steem blockchain.
return -1;
$result = wp_remote_post(steempress_sp_api_url . "/update", $data);
if (!isset($result->errors)) {
$data = $result['body'];
......
......@@ -111,7 +111,7 @@
<input type="checkbox" id="<?php echo $this->plugin_name; ?>-vote" name="<?php echo $this->plugin_name; ?>[vote]" <?php echo $options['vote'] == "off" ? '' : 'checked="checked"' ?>> Self vote<br>
<input type="checkbox" id="<?php echo $this->plugin_name; ?>-seo" name="<?php echo $this->plugin_name; ?>[seo]" <?php echo $options['seo'] == "off" ? '' : 'checked="checked"' ?>> Add the footer text to the end of the article.<br>
<input type="checkbox" id="<?php echo $this->plugin_name; ?>-featured" name="<?php echo $this->plugin_name; ?>[featured]" <?php echo $options['featured'] == "off" ? '' : 'checked="checked"' ?>> Add featured images on top of the steem post.<br>
<!--<input type="checkbox" id="<?php echo $this->plugin_name; ?>-update" name="<?php echo $this->plugin_name; ?>[update]" <?php echo $options['update'] == "off" ? '' : 'checked="checked"' ?>> Update the steem post when updating on wordpress.<br>-->
<input type="checkbox" id="<?php echo $this->plugin_name; ?>-update" name="<?php echo $this->plugin_name; ?>[update]" <?php echo $options['update'] == "off" ? '' : 'checked="checked"' ?>> Update the steem post when updating on wordpress.<br>
<br/>
......
......@@ -167,15 +167,16 @@ class Steempress_sp {
$this->loader->add_action( 'transition_post_status', $plugin_admin, 'Steempress_sp_post', 15, 3 );
//$this->loader->add_filter( 'bulk_actions-edit-post', $plugin_admin,'steempress_sp_bulk_update_action' );
$this->loader->add_filter( 'bulk_actions-edit-post', $plugin_admin,'steempress_sp_bulk_update_action' );
$this->loader->add_filter( 'bulk_actions-edit-post', $plugin_admin,'steempress_sp_bulk_publish_action' );
$this->loader->add_filter( 'handle_bulk_actions-edit-post', $plugin_admin,'steempress_sp_bulk_publish_handler', 10, 3 );
//$this->loader->add_filter( 'handle_bulk_actions-edit-post', $plugin_admin,'steempress_sp_bulk_update_handler', 10, 3 );
$this->loader->add_filter( 'handle_bulk_actions-edit-post', $plugin_admin,'steempress_sp_bulk_update_handler', 10, 3 );
$this->loader->add_action( 'admin_notices', $plugin_admin,'steempress_sp_bulk_publish_notice' );
//$this->loader->add_action( 'admin_notices', $plugin_admin,'steempress_sp_bulk_update_notice' );
$this->loader->add_action( 'admin_notices', $plugin_admin,'steempress_sp_bulk_update_notice' );
$this->loader->add_action( 'post_submitbox_misc_actions', $plugin_admin,'createSteemPublishField' );
$this->loader->add_action( 'post_submitbox_misc_actions', $plugin_admin,'create_update_checkbox' );
$this->loader->add_action( 'save_post', $plugin_admin,'saveSteemPublishField',8);
$this->loader->add_action('add_meta_boxes',$plugin_admin, 'steempress_sp_add_custom_box');
$this->loader->add_action('save_post', $plugin_admin, 'steempress_sp_save_post_data');
......
......@@ -36,6 +36,7 @@ if ( ! defined( 'WPINC' ) ) {
define( 'steempress_sp_compte', '2.0.2');
define( 'steempress_sp_api_url', 'https://api.steempress.io');
define( 'steempress_sp_twoway_api_url', 'https://two.steempress.io');
//define( 'steempress_sp_api_url', 'http://localhost:8001');
//define( 'steempress_sp_twoway_api_url', 'http://localhost:8002');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment