';
$newListEntry .= '' . esc_html(((empty($displayName) || $displayName == false) ? __("Unknown username", "blog2social") : $displayName)) . '
';
$newListEntry .= '' . esc_html($current_user_date) . '
';
$newListEntry .= '';
echo json_encode(array('result' => true, 'newListEntry' => $newListEntry));
wp_die();
} else if (isset($assignUserAuth['error_reason'])) {
echo json_encode(array('result' => false, 'error_reason' => $assignUserAuth['error_reason']));
wp_die();
} else {
echo json_encode(array('result' => false, 'error_reason' => 'invalid_data'));
wp_die();
}
}
echo json_encode(array('result' => false, 'error_reason' => 'default'));
wp_die();
} else {
echo json_encode(array('result' => false, 'error' => 'nonce'));
wp_die();
}
}
public function savePostTemplate() {
if (isset($_POST['b2s_security_nonce']) && (int) wp_verify_nonce($_POST['b2s_security_nonce'], 'b2s_security_nonce') === 1) {
if (isset($_POST['template_data']) && isset($_POST['networkId']) && (int) $_POST['networkId'] > 0) {
require_once(B2S_PLUGIN_DIR . 'includes/Options.php');
$options = new B2S_Options(get_current_user_id());
$post_template_result = false;
$link_no_cache_option = false;
if (B2S_PLUGIN_USER_VERSION >= 1) {
$post_template = $options->_getOption("post_template");
if ($post_template == false) {
$post_template = array();
}
$new_template = array();
foreach ($_POST['template_data'] as $type => $data) {
$limit = unserialize(B2S_PLUGIN_NETWORK_SETTINGS_TEMPLATE_DEFAULT)[$_POST['networkId']][$type]['short_text']['limit'];
$range_max = ((int) $limit != 0 && (int) $data['range_max'] > (int) $limit) ? (int) $limit : (int) $data['range_max'];
$excerpt_range_max = ((int) $limit != 0 && (int) $data['excerpt_range_max'] > (int) $limit) ? (int) $limit : (int) $data['excerpt_range_max'];
$new_template[$type] = array(
'format' => (isset($data['format'])) ? $data['format'] : false,
'content' => (isset($data['content'])) ? sanitize_textarea_field($data['content']) : unserialize(B2S_PLUGIN_NETWORK_SETTINGS_TEMPLATE_DEFAULT)[$_POST['networkId']][$type]['content'],
'short_text' => array(
'active' => 0,
'range_min' => (($range_max >= (int) unserialize(B2S_PLUGIN_NETWORK_SETTINGS_TEMPLATE_DEFAULT)[$_POST['networkId']][$type]['short_text']['range_max']) ? (int) unserialize(B2S_PLUGIN_NETWORK_SETTINGS_TEMPLATE_DEFAULT)[$_POST['networkId']][$type]['short_text']['range_min'] : ($range_max / 2)),
'range_max' => $range_max,
'excerpt_range_min' => (($excerpt_range_max >= (int) unserialize(B2S_PLUGIN_NETWORK_SETTINGS_TEMPLATE_DEFAULT)[$_POST['networkId']][$type]['short_text']['excerpt_range_max']) ? (int) unserialize(B2S_PLUGIN_NETWORK_SETTINGS_TEMPLATE_DEFAULT)[$_POST['networkId']][$type]['short_text']['excerpt_range_min'] : ($range_max / 2)),
'excerpt_range_max' => $excerpt_range_max,
'limit' => $limit
)
);
}
$post_template[$_POST['networkId']] = $new_template;
$post_template_result = $options->_setOption("post_template", $post_template);
}
if ((int) $_POST['networkId'] == 1 && isset($_POST['link_no_cache'])) {
$noCache = (int) $_POST['link_no_cache'];
$link_no_cache_option = $options->_setOption('link_no_cache', $noCache);
}
if ($post_template_result == true || $link_no_cache_option == true) {
echo json_encode(array('result' => true));
wp_die();
} else {
echo json_encode(array('result' => false));
wp_die();
}
}
echo json_encode(array('result' => false));
wp_die();
} else {
echo json_encode(array('result' => false, 'error' => 'nonce'));
wp_die();
}
}
public function loadDefaultPostTemplate() {
if (isset($_POST['b2s_security_nonce']) && (int) wp_verify_nonce($_POST['b2s_security_nonce'], 'b2s_security_nonce') === 1) {
if (isset($_POST['networkId']) && (int) $_POST['networkId'] > 0 && isset($_POST['networkType']) && isset(unserialize(B2S_PLUGIN_NETWORK_SETTINGS_TEMPLATE_DEFAULT)[$_POST['networkId']])) {
$default = unserialize(B2S_PLUGIN_NETWORK_SETTINGS_TEMPLATE_DEFAULT)[$_POST['networkId']];
require_once B2S_PLUGIN_DIR . 'includes/B2S/Network/Item.php';
$networkItem = new B2S_Network_Item();
$html = $networkItem->getEditTemplateFormContent($_POST['networkId'], $_POST['networkType'], $default);
echo json_encode(array('result' => true, 'html' => $html));
wp_die();
}
echo json_encode(array('result' => false));
wp_die();
} else {
echo json_encode(array('result' => false, 'error' => 'nonce'));
wp_die();
}
}
public function saveDraftData() {
if (isset($_POST['b2s_security_nonce']) && (int) wp_verify_nonce($_POST['b2s_security_nonce'], 'b2s_security_nonce') === 1) {
if (isset($_POST['post_id']) && (int) $_POST['post_id'] > 0) {
global $wpdb;
if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}b2s_posts_drafts'") == $wpdb->prefix . 'b2s_posts_drafts') {
$options = new B2S_Options(B2S_PLUGIN_BLOG_USER_ID);
$optionUserTimeZone = $options->_getOption('user_time_zone');
$userTimeZone = ($optionUserTimeZone !== false) ? $optionUserTimeZone : get_option('timezone_string');
$userTimeZoneOffset = (empty($userTimeZone)) ? get_option('gmt_offset') : B2S_Util::getOffsetToUtcByTimeZone($userTimeZone);
$date = B2S_Util::getCustomLocaleDateTime($userTimeZoneOffset);
$sqlCheckDraft = $wpdb->prepare("SELECT `id` FROM `{$wpdb->prefix}b2s_posts_drafts` WHERE `blog_user_id` = %d AND `post_id` = %d", B2S_PLUGIN_BLOG_USER_ID, (int) $_POST['post_id']);
$draftEntry = $wpdb->get_var($sqlCheckDraft);
if ($draftEntry !== NULL && (int) $draftEntry > 0) {
$wpdb->update($wpdb->prefix . 'b2s_posts_drafts', array('data' => serialize($_POST), 'last_save_date' => $date), array('id' => (int) $draftEntry));
} else {
$wpdb->insert($wpdb->prefix . 'b2s_posts_drafts', array('blog_user_id' => B2S_PLUGIN_BLOG_USER_ID, 'post_id' => (int) $_POST['post_id'], 'data' => serialize($_POST), 'last_save_date' => $date));
}
echo json_encode(array('result' => true));
wp_die();
}
}
echo json_encode(array('result' => false));
wp_die();
} else {
echo json_encode(array('result' => false, 'error' => 'nonce'));
wp_die();
}
}
public function deleteDraft() {
if (isset($_POST['b2s_security_nonce']) && (int) wp_verify_nonce($_POST['b2s_security_nonce'], 'b2s_security_nonce') === 1) {
if (isset($_POST['draftId']) && (int) $_POST['draftId'] > 0) {
global $wpdb;
$wpdb->delete($wpdb->prefix . 'b2s_posts_drafts', array('id' => (int) $_POST['draftId'], 'blog_user_id' => B2S_PLUGIN_BLOG_USER_ID), array('%d', '%d'));
echo json_encode(array('result' => true));
wp_die();
}
echo json_encode(array('result' => false));
wp_die();
} else {
echo json_encode(array('result' => false, 'error' => 'nonce'));
wp_die();
}
}
public function authNetworkLogin() {
if (isset($_POST['b2s_security_nonce']) && (int) wp_verify_nonce($_POST['b2s_security_nonce'], 'b2s_security_nonce') === 1) {
if (isset($_POST['username']) && !empty($_POST['username']) && isset($_POST['password']) && !empty($_POST['password'])) {
require_once(B2S_PLUGIN_DIR . 'includes/B2S/Api/Network/Pinterest.php');
$location = 'en';
if(isset($_POST['location']) && !empty($_POST['location'])){
$location = $_POST['location'];
}
$pt = new B2S_Api_Network_Pinterest($location);
$authorize = $pt->authorize(sanitize_text_field($_POST['username']), sanitize_text_field($_POST['password']));
if (isset($authorize['error']) && (int) $authorize['error'] == 0 && isset($authorize['identData']) && !empty($authorize['identData'])) {
$getBoards = $pt->getPinBoards();
if (isset($getBoards['error']) && (int) $getBoards['error'] == 0 && isset($getBoards['data']) && !empty($getBoards['data'])) {
$html = '';
foreach ($getBoards['data'] as $k => $v) {
$html .= '