nxs_options = $this->getAPOptions();} //## Constructor function NS_SNAutoPoster() { } //## Initialization function function init() { $this->getAPOptions(); } //## Administrative Functions //## Options loader function function getAPOptions() { global $nxs_isWPMU, $blog_id; $dbMUOptions = array(); //## Some Default Values //$options = array('nsOpenGraph'=>1); $dbOptions = get_option($this->dbOptionsName); $this->nxs_ntoptions = get_site_option($this->dbOptionsName); if ($nxs_isWPMU && $blog_id>1) { switch_to_blog(1); $dbMUOptions = get_option($this->dbOptionsName); if (function_exists('nxs_getInitAdd')) nxs_getInitAdd($dbMUOptions); restore_current_blog(); $dbOptions['lk'] = $dbMUOptions['lk']; $dbOptions['ukver'] = $dbMUOptions['ukver']; $dbOptions['uklch'] = $dbMUOptions['uklch']; $dbOptions['uk'] = $dbMUOptions['uk']; } if (!empty($dbOptions) && is_array($dbOptions)) foreach ($dbOptions as $key => $option) if (trim($key)!='') $options[$key] = $option; if ( (!$nxs_isWPMU || $blog_id==1) && function_exists('nxs_getInitAdd')) nxs_getInitAdd($options); //$ttt = function_exists('nxs_getInitAdd'); var_dump($ttt); if (isset($options['uk']) && $options['uk']!='') $options['uk']='API'; if (defined('NXSAPIVER') && $options['ukver']!=NXSAPIVER){$options['ukver']=NXSAPIVER; update_option($this->dbOptionsName, $options);} $options['isMA'] = function_exists('nxs_doSMAS1') && isset($options['lk']) && isset($options['uk']) && $options['uk']!=''; $options['isMU'] = function_exists('showSNAP_WPMU_OptionsPageExt') && isset($options['lk']) && isset($options['uk']) && $options['uk']!=''; $options['isMUx'] = function_exists('showSNAP_WPMU_OptionsPageExtX') && isset($options['lk']) && isset($options['uk']) && $options['uk']!=''; // prr($options); if (!isset($options['isPro']) || $options['isPro']!='1'){ //## Upgrade from non-pro version $optPro = array();foreach ($options as $indx => $opt){ if (substr($indx, 0, 2)=='fb') $optPro['fb'][0][$indx] = $opt; elseif (substr($indx, 0, 2)=='gp') $optPro['gp'][0][$indx] = $opt; elseif (substr($indx, 0, 2)=='tw') $optPro['tw'][0][$indx] = $opt; elseif (substr($indx, 0, 2)=='tr') $optPro['tr'][0][$indx] = $opt; elseif (substr($indx, 0, 2)=='bg') $optPro['bg'][0][$indx] = $opt; elseif (substr($indx, 0, 2)=='li') $optPro['li'][0][$indx] = $opt; elseif (substr($indx, 0, 2)=='pn') $optPro['pn'][0][$indx] = $opt; elseif ($indx=='doFB') $optPro['fb'][0][$indx] = $opt; elseif ($indx=='doGP') $optPro['gp'][0][$indx] = $opt; elseif ($indx=='doTW') $optPro['tw'][0][$indx] = $opt; elseif ($indx=='doTR') $optPro['tr'][0][$indx] = $opt; elseif ($indx=='doBG') $optPro['bg'][0][$indx] = $opt; elseif ($indx=='doLI') $optPro['li'][0][$indx] = $opt; elseif ($indx=='doPN') $optPro['pn'][0][$indx] = $opt; elseif (trim($indx)!='') $optPro[$indx] = $opt; if ($options['twAccTokenSec']!='') $optPro['tw'][0]['twOK'] = '1'; if ($options['bgBlogID']!='') $optPro['bg'][0]['bgOK'] = '1'; $optPro['isPro'] = '1'; } //## Update the options for the panel $options = $optPro; update_option($this->dbOptionsName, $options); } // if(!$options['isMA']) $options = nxs_snapCleanup($options); return $options; } function showSNAP_WPMU_OptionsPage(){ global $nxs_snapAvNts, $nxs_snapThisPageUrl, $nxsOne, $wpdb, $nxs_isWPMU; $nxsOne = ''; $options = $this->nxs_options; $this->NS_SNAP_ShowPageTop(); if ($nxs_isWPMU && function_exists('showSNAP_WPMU_OptionsPageExt')) { showSNAP_WPMU_OptionsPageExt($this); } elseif ($nxs_isWPMU && function_exists('showSNAP_WPMU_OptionsPageExtX')) { ?>

You are running SNAP
This version does not fully support Wordpress Multisite (ex Wordpress MU) Advanced Features. SNAP is available for all sites/blogs in your networks and each individual blog admin can setup and manage it.
Please upgrade to SNAP For Wordpress Multisite if you need advanced Super Admin management of SNAP for sites/blogs in your networks. Please see here for more info

Please contact us if you got the SNAP PRO before Oct 1st, 2012. You may be eligible for upgrade discount.



You are running SNAP
This version does not support Wordpress Multisite (ex Wordpress MU).
Please upgrade to SNAP Pro for Wordpress Multisite



FAQ:

Question: I am not running Wordpress Multisite! Why I am seeing this?
Answer: Your Wordpress is configured to run as a Wordpress Multisite. Please open your wp-config.php and change:

define('WP_ALLOW_MULTISITE', true);
to
define('WP_ALLOW_MULTISITE', false);

and

define('MULTISITE', true);
to
define('MULTISITE', false);

Question: I am running Wordpress Multisite, but I need SNAP on one blog only? Can I use it?
Answer:We are sorry, but it is not possible to run "SNAP Free" on Wordpress Multisite. You need to either upgrade plugin to "SNAP Pro" to run it on one blog or to "SNAP Pro for WPNU" to run it on all blogs or disable Wordpress Multisite.



You are running SNAP
This version does not fully support Wordpress Multisite (ex Wordpress MU).


You can use SNAP for your main blog only. Click here to setup it.

Please upgrade to SNAP Pro for Wordpress Multisite to get all features:
- All Blogs/Sites autopost to networks configured by Super Admin
- Each Blog/Site Admin can configure and auto-post to it's own networks
- Super Admin can enable/disable auto-posting for each site and the whole network
- Super Admin can also manage/setup/disable/override SNAP settings for each Blog/Site.

nxs_options; //prr($options); //if($acid==1) $options = $this->nxs_options; else { switch_to_blog($acid); $options = $this->getAPOptions(); } if (isset($_POST['upload_NS_SNAutoPoster_settings'])) { if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") {array_walk_recursive($_POST, 'nsx_stripSlashes');} array_walk_recursive($_POST, 'nsx_fixSlashes'); //## Import Settings $secCheck = wp_verify_nonce($_POST['nxsChkUpl_wpnonce'], 'nxsChkUpl'); if ($secCheck!==false && isset($_FILES['impFileSettings_button']) && is_uploaded_file($_FILES['impFileSettings_button']['tmp_name'])) { $fileData = trim(file_get_contents($_FILES['impFileSettings_button']['tmp_name'])); while (substr($fileData, 0,1)!=='a') $fileData = substr($fileData, 1); $uplOpt = maybe_unserialize($fileData); if (is_array($uplOpt) && isset($uplOpt['imgNoCheck'])) { $options = $uplOpt; update_option($this->dbOptionsName, $options); } else { ?>

Incorrect Import file.

setNTSettings($_POST[$avNt['lcode']], $options[$avNt['lcode']]); $options[$avNt['lcode']] = $ntOpt; } if (isset($_POST['apCats'])) $options['apCats'] = $_POST['apCats']; if (isset($_POST['nxsHTDP'])) $options['nxsHTDP'] = $_POST['nxsHTDP']; if (isset($_POST['ogImgDef'])) $options['ogImgDef'] = $_POST['ogImgDef']; if (isset($_POST['featImgLoc'])) $options['featImgLoc'] = $_POST['featImgLoc']; if (isset($_POST['anounTagLimit'])) $options['anounTagLimit'] = $_POST['anounTagLimit']; if (isset($_POST['featImgLocPrefix'])) $options['featImgLocPrefix'] = $_POST['featImgLocPrefix']; if (isset($_POST['featImgLocArrPath'])) $options['featImgLocArrPath'] = $_POST['featImgLocArrPath']; if (isset($_POST['nxsURLShrtnr']))$options['nxsURLShrtnr'] = $_POST['nxsURLShrtnr']; if (isset($_POST['bitlyUname'])) $options['bitlyUname'] = $_POST['bitlyUname']; if (isset($_POST['bitlyAPIKey'])) $options['bitlyAPIKey'] = $_POST['bitlyAPIKey']; if (isset($_POST['YOURLSKey'])) $options['YOURLSKey'] = $_POST['YOURLSKey']; if (isset($_POST['YOURLSURL'])) $options['YOURLSURL'] = $_POST['YOURLSURL']; if (isset($_POST['gglAPIKey'])) $options['gglAPIKey'] = $_POST['gglAPIKey']; if ($options['nxsURLShrtnr']=='B' && (trim($_POST['bitlyAPIKey'])=='' || trim($_POST['bitlyAPIKey'])=='')) $options['nxsURLShrtnr'] = 'G'; if ($options['nxsURLShrtnr']=='Y' && (trim($_POST['YOURLSKey'])=='' || trim($_POST['YOURLSURL'])=='')) $options['nxsURLShrtnr'] = 'G'; if (isset($_POST['nsOpenGraph'])) $options['nsOpenGraph'] = $_POST['nsOpenGraph']; else $options['nsOpenGraph'] = 0; if (isset($_POST['imgNoCheck'])) $options['imgNoCheck'] = 0; else $options['imgNoCheck'] = 1; if (isset($_POST['useForPages'])) $options['useForPages'] = 1; else $options['useForPages'] = 0; if (isset($_POST['showPrxTab'])) $options['showPrxTab'] = 1; else $options['showPrxTab'] = 0; if (isset($_POST['useRndProxy'])) $options['useRndProxy'] = 1; else $options['useRndProxy'] = 0; if (isset($_POST['prxList'])) $options['prxList'] = $_POST['prxList']; if (isset($_POST['addURLParams'])) $options['addURLParams'] = $_POST['addURLParams']; if (isset($_POST['riActive'])) $options['riActive'] = 1; else $options['riActive'] = 0; if (isset($_POST['riHowManyPostsToTrack'])) $options['riHowManyPostsToTrack'] = $_POST['riHowManyPostsToTrack']; if (isset($_POST['useUnProc'])) $options['useUnProc'] = $_POST['useUnProc']; else $options['useUnProc'] = 0; if (isset($_POST['nxsCPTSeld'])) $options['nxsCPTSeld'] = serialize($_POST['nxsCPTSeld']); if (isset($_POST['post_category'])) { $pk = $_POST['post_category']; if (!is_array($pk)) { $pk = urldecode($pk); parse_str($pk); } $cIds = get_all_category_ids(); if(is_array($pk) && $cIds) $options['exclCats'] = serialize(array_diff($cIds, $pk)); else $options['exclCats'] = ''; } //prr($options['exclCats']); if (!isset($_POST['whoCanSeeSNAPBox'])) $_POST['whoCanSeeSNAPBox'] = array(); $_POST['whoCanSeeSNAPBox'][] = 'administrator'; if (isset($_POST['whoCanSeeSNAPBox'])) $options['whoCanSeeSNAPBox'] = $_POST['whoCanSeeSNAPBox']; if (!isset($_POST['whoCanMakePosts'])) $_POST['whoCanMakePosts'] = array(); $_POST['whoCanMakePosts'][] = 'administrator'; if (isset($_POST['whoCanMakePosts'])) $options['whoCanMakePosts'] = $_POST['whoCanMakePosts']; if (isset($_POST['skipSecurity'])) $options['skipSecurity'] = 1; else $options['skipSecurity'] = 0; if ($nxs_isWPMU && (!isset($options['suaMode'])||$options['suaMode'] == '')) $options['suaMode'] = $nxs_tpWMPU; $editable_roles = get_editable_roles(); foreach ( $editable_roles as $roleX => $details ) {$role = get_role($roleX); $role->remove_cap('see_snap_box'); $role->remove_cap('make_snap_posts'); } foreach ($options['whoCanSeeSNAPBox'] as $uRole) { $role = get_role($uRole); $role->add_cap('see_snap_box'); } foreach ($options['whoCanMakePosts'] as $uRole) { $role = get_role($uRole); $role->add_cap('make_snap_posts'); } update_option($this->dbOptionsName, $options); // prr($options); ?>

0) {$isNoNts = false; break;} $category_ids = get_all_category_ids(); if(isset($options['exclCats'])) $pk = maybe_unserialize($options['exclCats']); else $pk = ''; if ( is_array($category_ids) && is_array($pk) && count($category_ids) == count($pk)) { ?>

All your categories are excluded from auto-posting. Nothing will be auto-posted. Please Click "Settings Tab" and select some categories.

NS_SNAP_ShowPageTop(); ?> Please see the detailed installation/configuration instructions (will open in a new tab)
Tip: If autoposting works when you click "Test" buttons, but is not working when you publish new posts, try to switch from "Scheduled" to "Immediately" in the Plugin Settings->Other Settings->How to make auto-posts. [Hide]

Add new account
Arrow You can add Facebook, Twitter, Google+, Pinterest, LinkedIn, Tumblr, Blogger/Blogspot, Delicious, etc accounts


XAdd New Network:
showNewNTSettings(0); } else { $mt = 1+max(array_keys($options[$avNt['lcode']])); if (function_exists('nxs_doSMAS1')) nxs_doSMAS1($ntClInst, $mt); else nxs_doSMAS($avNt['name'], $avNt['code'].$mt); }} ?>
0) { $ntClInst->showGenNTSettings($options[$avNt['lcode']]); } // else $ntClInst->showNewNTSettings(0); } if ($isNoNts) { ?>


You don't have any configured social networks yet. Please click "Add new account" button.

<-- ()

"Immediately" - Once you click "Publish" button plugin starts pushing your update to configured social networks. At this time you need to wait and look at the turning circle. Some APIs are pretty slow, so you have to wait and wait and wait until all updates are posted and page released back to you.', 'nxs_snap') ?>

"Scheduled" - Releases the page immediately back to you, so you can proceed with something else and it schedules all auto-posting jobs to your WP-Cron. This is much faster and much more efficient, but it could not work if your WP-Cron is disabled or broken.', 'nxs_snap') ?>
/> -
/> -
       highly recomended to setup a proper cron job of fix WP Cron instead', 'nxs_snap') ?>.

/>

$details ) { $name = translate_user_role($details['name'] ); echo ' '.$name; if ($role=='administrator') echo ' - Somebody who has access to all the administration features'; if ($role=='editor') echo " - Somebody who can publish and manage posts and pages as well as manage other users' posts, etc. "; if ($role=='author') echo ' - Somebody who can publish and manage their own posts '; if ($role=='contributor') echo ' - Somebody who can write and manage their posts but not publish them'; if ($role=='subscriber') echo ' - Somebody who can only manage their profile'; echo '
'; } ?>

$details ) { $name = translate_user_role($details['name'] ); echo ' '.$name; if ($role=='administrator') echo ' - Somebody who has access to all the administration features'; if ($role=='editor') echo " - Somebody who can publish and manage posts and pages as well as manage other users' posts, etc. "; if ($role=='author') echo ' - Somebody who can publish and manage their own posts '; if ($role=='contributor') echo ' - Somebody who can write and manage their posts but not publish them'; if ($role=='subscriber') echo ' - Somebody who can only manage their profile'; echo '
'; } ?>

/>


true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator); if ($options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types); ?>
$cptName){ if (in_array($cptID, $nxsCPTSeld)) $dCh = ' checked="checked" '; else $dCh = ""; ?>

Uncheck categories that you would like NOT to auto-post by default. Assigning the uncheked category to the new blogpost will turn off auto-posting to all configured networks.', 'nxs_snap') ?>
Check all  |  UnCheck all
    0 ) $selCats = array_diff($category_ids, $pk); else $selCats = $category_ids; $args = array( 'descendants_and_self' => 0, 'selected_cats' => $selCats, 'taxonomy' => 'category', 'checked_ontop' => false); if (function_exists('wp_terms_checklist')) wp_terms_checklist(0, $args ); ?>

Please use %SURL% in "Message Format" to get shortened urls.
/> goo.gl - Enter goo.gl API Key below [Optional]
       goo.gl  API Key:      
/> Wordpress Built-in Shortener (wp.me if you use Jetpack)
/> bit.ly - Enter bit.ly username and API Key below
       bit.ly Username:
       bit.ly  API Key:      
/> YOURLS (Your Own URL Shortener) -  YOURLS API URL - usually sonething like http://yourdomain.cc/yourls-api.php; YOURLS API Secret Signature Token can be found in your YOURLS Admin Panel->Tools
       YOURLS API URL:
       YOURLS API Secret Signature Token:   

[]

Plugin will automatically grab the comments posted on Social Networks and insert them as "Comments to your post". Plugin will check for the new comments every hour.
/> Enable "Comments Import"
How many posts should be tracked: " />
Setting two many will degrade your website's performance. 10-20 posts are recommended

[]


Any text must be URL Encoded
Example: utm_source=%NTCODE%&utm_medium=%ACCNAME%&utm_campaign=SNAP%2Bfrom%2B%SITENAME%', 'nxs_snap') ?>


" />


/>

/> Verify "Featured" Image

/>
This feature could interfere with some plugins using post processing functions incorrectly. Your site could become messed up, have troubles displaying content or start giving you "ob_start() [ref.outcontrol]: Cannot use output buffering in output buffering display handlers" errors.', 'nxs_snap') ?>




[]

[]

Show "Proxies" Tab

/> Show "Proxies" Tab Advanced Setting. Check to enable "Proxies" tab where you can setup autoposting proxies.

Refresh Showing last 150 records Clear Log

['.$logline['date'].'] - ['.$logline['act'].']'.$ntInfo.'- '.$logline['msg'].' '.$logline['extInfo'].'
'; } ?>

Setup/Installation/Configuration Instructions

Have questions/suggestions?

===> Contact us <===

Have troubles/problems/found a bug?

===> Open support ticket <===

Like the Plugin? Would you like to support developers?

Here is what you can do:
Get the "Pro" Edition. You will be able to add several accounts for each network as well as post to Google+, Pinterest and LinkedIn company pages. Done! Thank you!
Rate the plugin 5 stars at wordpress.org page.
Write a blogpost about the plugin and don't forget to auto-post this blogpost to all your social networks ;-).


Solutions for some common problems

Problem: I can't create an app on developers.facebook.com/apps. When I am trying to enter that page it redirects me back to my account?
Solution: Facebook "Business" or "Advertising" accounts can't manage apps. This is an unavoidable Facebook limitation. Only real user accounts are able to create and manage apps. Please login to Facebook as a personal account to be able to create app. You will need to add your personal Facebook account as "Administrator" to your page..

Problem: When I follow the instructions to allow plugin authorize/access to my Facebook/Twitter/Tumblr/LinkedIn account, it redirects me to my "Google Analytics for WordPress Configuration" page.
Solution: It's a known issue. Google Analytics plugin hijacks the authorization workflow. Please temporary deactivate Google Analytics plugin, do all authorizations and then activate it back. There are some other plugins ("Blog Promoter", "Tweet Old Post", etc.. ) that could also hijack the authorization. Solution is the same: Deactivate the other plugin, do authorization, reactivate it.

Problem: Plugin breaks NextGen galleries. I got error "Fatal error: Class 'nggMeta' not found".
Solution:There is a known bug in NextGen galleries that was reported back to them over a year ago, but still hasn't been fixed. Any plugin calling standard wordpress function apply_filters('the_content' will break NextGen galleries. We have posted the solution here: http://wordpress.org/support/topic/plugin-nextgen-gallery-fatal-error-insert-picture-in-event?replies=4

Problem: When I publish a new post to Facebook I am getting this weird Twitter Error: Error:(#100) The status you are trying to publish is a duplicate of, or too similar to, one that we recently posted to Twitter.
Solution: Your Facebook is already auto-posting to Twitter. When it sees the same tweet made by our plugin it fails with this error. You need to either unlink your Facebook from Twitter or disable Twitter auto-posting from our plugin. If you decide to unlink your Facebook from Twitter:
Go to http://www.facebook.com/twitter and remove the link to twitter from the affected wall (Click on "Unlink from Twitter").

Problem: Facebook Error: "The user hasn't authorized the application to perform this action"
Solution: The most popular cause for "The user hasn't authorized the application to perform this action" is that your domain is not configured for your app.
Please read and carefully follow the installation instructions:
You missed/messed steps 1.4 and 1.5 from Facebook section:
4. Click "Website", enter your website URL
5. Enter your domain to the App Domain. Domain should be the same domain from URL that you have entered to the "Website" during the step 4.

Problem: Facebook Error: SSL certificate problem, verify that the CA cert is OK. Details:error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Solution: This error means that cURL is misconfigured on your server. Most probably curl ssl(open SSL) is broken or it simply can't find the certificates at the pointed location. Please contact your hosting provider and ask them to fix this.
http://curl.haxx.se/docs/sslcerts.html
Unlike Twitter or Google+ that could be automatically switched to non-SSL connections in such cases, Facebook requires to be accessed by SSL at all times.

Problem: Twitter Error: {"error":"Read-only application cannot POST","request":"/1/statuses/update.json"}
Solution:You just need to follow the instructions step by step. Please don't skip anything.

Please see #4 and #5 for Twitter:

4. Click "Settings" tab. Scroll to the "Application type", change Access level from "Read Only" to "Read and Write". Click "Update this Twitter application settings".
5. Come back to "Details" tab. Scroll to the "Your access token" and click "Create my access token" button. Refresh page and notice "Access token" and "Access token secret". Make sure you have "Read and Write" access level.

 
nxs_options; ?>


This version of the plugin is not compatible with Wordpress Multisite Edition. Please contact your Network Admin for the upgrade. nxs_options; $nxsOne = NextScripts_SNAP_Version; if (defined('NXSAPIVER')) $nxsOne .= " (API Version: ".NXSAPIVER.")"; ?>

[]
and get Google+ and Pinterest Auto-Posting?', 'nxs_snap'); ?>
[]     []

: [Pro - Multiple Accounts Edition]   [Single Accounts Edition] - PRO - Multiple Accounts Edition



Error: No CURL Found - Social Networks AutoPoster needs the CURL PHP extension. Please install it or contact your hosting company to install it.

"); } if (stripos($disabled_functions, 'curl_exec')!==false) { echo ("
curl_exec function is disabled in php.ini - Social Networks AutoPoster needs the CURL PHP extension. Please enable it or contact your hosting company to enable it.

"); } /* if ((defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE==true) || (defined('MULTISITE') && MULTISITE==true) ) { echo "


Sorry, we do not support Multiuser Wordpress at this time"; return; } */ ?>

deactivate Google Analytics plugin, do all authorizations and then activate it back.', 'nxs_snap' ), $plgnsLink ); ?>

nxs_options; // echo "| NS_SNAP_SavePostMetaTags - ".$id." |"; $post = get_post($id); if ($post->post_type=='revision' && $post->post_status=='inherit' && $post->post_parent!='0') return; if (isset($_POST["snapEdIT"])) $nspost_edit = $_POST["snapEdIT"]; //echo "| snapEdIT |"; // prr($nspost_edit); if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'"){ array_walk_recursive($_POST, 'nsx_stripSlashes'); } $snap_isAutoPosted = get_post_meta($id, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1' && $post->post_status=='future') { delete_post_meta($id, 'snap_isAutoPosted'); add_post_meta($id, 'snap_isAutoPosted', '2'); } if (isset($nspost_edit) && !empty($nspost_edit)) { delete_post_meta($id, 'snapEdIT'); add_post_meta($id, 'snapEdIT', '1' ); foreach ($nxs_snapAvNts as $avNt) { if (count($options[$avNt['lcode']])>0 && isset($_POST[$avNt['lcode']]) && count($_POST[$avNt['lcode']])>0) { $savedMeta = maybe_unserialize(get_post_meta($id, 'snap'.$avNt['code'], true)); if(is_array($_POST[$avNt['lcode']])) { $ii=0; foreach ($_POST[$avNt['lcode']] as $pst ) { // echo "#############################################################################"; prr($pst); if (is_array($pst) && $pst['do'.$avNt['code']]=='' && $_POST[$avNt['lcode']][$ii]['do'.$avNt['code']]=='') $_POST[$avNt['lcode']][$ii]['do'.$avNt['code']]= 0; $ii++; } } $newMeta = $_POST[$avNt['lcode']]; if (is_array($savedMeta) && is_array($newMeta)) $newMeta = nxsMergeArraysOV($savedMeta, $newMeta); // echo "##### ".$id."| snap".$avNt['code']; prr($savedMeta); echo "||"; prr($newMeta);// $newMeta = 'AAA'; delete_post_meta($id, 'snap'.$avNt['code']); add_post_meta($id, 'snap'.$avNt['code'], serialize($newMeta)); } } } // prr($_POST); } function NS_SNAP_AddPostMetaTags() { global $post, $nxs_snapAvNts, $plgn_NS_SNAutoPoster; $post_id = $post; if (is_object($post_id)) $post_id = $post_id->ID; if (!is_object($post)) $post = get_post($post_id); if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; ?>
post_status != "publish" ) { ?>
 
0) { $ntClInst = new $clName(); $ntClInst->showEdPostNTSettings($options[$avNt['lcode']], $post); } } ?>
Edit function NS_SNAP_addCustomBoxes() { add_meta_box( 'NS_SNAP_AddPostMetaTags', __( 'NextScripts: Social Networks Auto Poster - Post Options', 'nxs_snap' ), array($this, 'NS_SNAP_AddPostMetaTags'), 'post' ); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; if ($options['useForPages']=='1') add_meta_box( 'NS_SNAP_AddPostMetaTags', __( 'NextScripts: Social Networks Auto Poster - Post Options', 'nxs_snap' ), array($this, 'NS_SNAP_AddPostMetaTags'), 'page' ); $args=array('public'=>true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator); if ((isset($options['nxsCPTSeld'])) && $options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types); //prr($nxsCPTSeld); foreach ($post_types as $cptID=>$cptName) if (in_array($cptID, $nxsCPTSeld)){ add_meta_box( 'NS_SNAP_AddPostMetaTags', __('NextScripts: Social Networks Auto Poster - Post Options', 'nxs_snap'), array($this, 'NS_SNAP_AddPostMetaTags'), $cptID ); } } } } if (class_exists("NS_SNAutoPoster")) { nxs_checkAddLogTable(); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); } //## Delete Account if (!function_exists("ns_delNT_ajax")) { function ns_delNT_ajax(){ check_ajax_referer('nsDN'); $indx = (int)$_POST['id']; global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; unset($options[$_POST['nt']][$indx]); if (is_array($options)) update_option('NS_SNAutoPoster', $options); }} if (!function_exists("nsAuthFBSv_ajax")) { function nsAuthFBSv_ajax() { check_ajax_referer('nsFB'); $pgID = $_POST['pgID']; $fbs = array(); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; foreach ($options['fb'] as $two) { if ($two['fbPgID']==$pgID) $two['wfa']=time(); $fbs[] = $two; } $options['fb'] = $fbs; if (is_array($options)) update_option('NS_SNAutoPoster', $options); }} if (!function_exists("nsGetBoards_ajax")) { function nsGetBoards_ajax() { global $nxs_gCookiesArr; check_ajax_referer('getBoards'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']); $loginError = doConnectToPinterest($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";} $gPNBoards = doGetBoardsFromPinterest(); $options['pn'][$_POST['ii']]['pnBoardsList'] = base64_encode($gPNBoards); $options['pn'][$_POST['ii']]['pnSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gPNBoards; die(); } } if (!function_exists("nsGetGPCats_ajax")) { function nsGetGPCats_ajax() { global $nxs_gCookiesArr; check_ajax_referer('getGPCats'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']); $loginError = doConnectToGooglePlus2($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";} $gGPCCats = doGetCCatsFromGooglePlus($_POST['c']); $options['gp'][$_POST['ii']]['gpCCatsList'] = base64_encode($gGPCCats); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gGPCCats; die(); } } if (!function_exists("nsGetWLBoards_ajax")) { function nsGetWLBoards_ajax() { global $nxs_gCookiesArr; check_ajax_referer('getWLBoards'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; if (get_magic_quotes_gpc() || $_POST['nxs_mqTest']=="\'") { $_POST['u'] = stripslashes($_POST['u']); $_POST['p'] = stripslashes($_POST['p']);} $_POST['p'] = trim($_POST['p']); $u = trim($_POST['u']); $loginError = doConnectToWaNeLo($_POST['u'], substr($_POST['p'], 0, 5)=='g9c1a'?nsx_doDecode(substr($_POST['p'], 5)):$_POST['p'] ); if ($loginError!==false) {echo $loginError; return "BAD USER/PASS";} $gWLBoards = doGetBoardsFromWaNeLo(); $options['wl'][$_POST['ii']]['wlBoardsList'] = base64_encode($gWLBoards); $options['wl'][$_POST['ii']]['wlSvC'] = serialize($nxs_gCookiesArr); if (is_array($options)) update_option('NS_SNAutoPoster', $options); echo $gWLBoards; die(); } } if (!function_exists("nxs_clLgo_ajax")) { function nxs_clLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); global $wpdb; //update_option('NS_SNAutoPosterLog', ''); $wpdb->query( 'DELETE FROM '.$wpdb->prefix . 'nxs_log' ); echo "OK"; }} if (!function_exists("nxs_rfLgo_ajax")) { function nxs_rfLgo_ajax() { check_ajax_referer('nxsSsPageWPN'); echo "Y:"; //$log = get_option('NS_SNAutoPosterLog'); $logInfo = maybe_unserialize(get_option('NS_SNAutoPosterLog')); $logInfo = nxs_getnxsLog(); if (is_array($logInfo))foreach (array_reverse($logInfo) as $logline) { if ($logline['type']=='E') $actSt = "color:#FF0000;"; elseif ($logline['type']=='M') $actSt = "color:#585858;"; elseif ($logline['type']=='BG') $actSt = "color:#008000; font-weight:bold;"; elseif ($logline['type']=='I') $actSt = "color:#0000FF;"; elseif ($logline['type']=='W') $actSt = "color:#DB7224;"; elseif ($logline['type']=='BI') $actSt = "color:#0000FF; font-weight:bold;"; elseif ($logline['type']=='GR') $actSt = "color:#008080;"; elseif ($logline['type']=='S') $actSt = "color:#005800; font-weight:bold;"; else $actSt = "color:#585858;"; if ($logline['type']=='E') $msgSt = "color:#FF0000;"; elseif ($logline['type']=='BG') $msgSt = "color:#008000; font-weight:bold;"; else $msgSt = "color:#585858;"; if ($logline['nt']!='') $ntInfo = ' ['.$logline['nt'].'] '; else $ntInfo = ''; echo '['.$logline['date'].'] - ['.$logline['act'].']'.$ntInfo.'- '.$logline['msg'].' '.$logline['extInfo'].'
'; } }} //## Initialize the admin panel if the plugin has been activated if (!function_exists("nxs_AddSUASettings")) { function nxs_AddSUASettings() { global $plgn_NS_SNAutoPoster, $nxs_plurl; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; add_menu_page('Social Networks Auto Poster', 'Social Networks Auto Poster', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAP_WPMU_OptionsPage'), $nxs_plurl.'img/snap-icon12.png'); }} //## Initialize the admin panel if the plugin has been activated if (!function_exists("NS_SNAutoPoster_ap")) { function NS_SNAutoPoster_ap() { global $plgn_NS_SNAutoPoster, $nxs_plurl; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; if (function_exists('add_options_page')) { add_options_page('Social Networks Auto Poster', '{SNAP} Social Networks Auto Poster', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAutoPosterOptionsPage')); }}} if (!function_exists("NS_SNAutoPoster_apx")) { function NS_SNAutoPoster_apx() { global $plgn_NS_SNAutoPoster, $nxs_plurl; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; if (function_exists('add_options_page')) { add_options_page('Social Networks Auto Poster', '{SNAP} Social Networks Auto Poster', 'manage_options', basename(__FILE__), array(&$plgn_NS_SNAutoPoster, 'showSNAutoPosterOptionsPagex')); }}} //## Main Function to Post if (!function_exists("nxs_snapPublishTo")) { function nxs_snapPublishTo($postArr, $type='', $aj=false) { global $plgn_NS_SNAutoPoster, $nxs_snapAvNts, $blog_id, $nxs_tpWMPU; // echo " | nxs_doSMAS2 | "; prr($postArr); if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; if(is_object($postArr)) $postID = $postArr->ID; else { $postID = $postArr; $postArr = get_post($postID); } $isPost = isset($_POST["snapEdIT"]); if ($isPost && $options['skipSecurity']!='1' && !current_user_can("make_snap_posts") && !current_user_can("manage_options")) { nxs_addToLogN('I', 'Skipped', '', 'Current user can\'t autopost - Post ID:('.$postID.')' ); return; } $postUser = $postArr->post_author; if ($options['skipSecurity']!='1' && !user_can( $postUser, "make_snap_posts" ) && !user_can( $postUser, "manage_options")){ nxs_addToLogN('I', 'Skipped', '', 'User ID '.$postUser.' can\'t autopost - Post ID:('.$postID.')' ); return; } if ($isPost) $plgn_NS_SNAutoPoster->NS_SNAP_SavePostMetaTags($postID); if (function_exists('nxs_doSMAS2')) { nxs_doSMAS2($postArr, $type, $aj); return; } else { $options = $plgn_NS_SNAutoPoster->nxs_options; $ltype=strtolower($type); if ($nxs_tpWMPU=='S') { switch_to_blog(1); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); $options = $plgn_NS_SNAutoPoster->nxs_options; restore_current_blog(); } if (!isset($options['nxsHTDP']) || $options['nxsHTDP']=='S') { if(isset($_POST["snapEdIT"]) && $_POST["snapEdIT"]=='1') { $publtype='S'; $delay = rand(2,10); } else $publtype='A'; } else $publtype = 'I'; nxs_addToLogN('BG', 'Start =- ', '', '------=========#### NEW AUTO-POST REQUEST '.($blog_id>1?'BlogID:'.$blog_id:'').' PostID:('.$postID.') '.($publtype=='S'?'Scheduled +'.$delay:($publtype=='A'?'Non Human':'Immediate')).' ####=========------'); $post = get_post($postID); $args=array( 'public' => true, '_builtin' => false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator); $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted=='1') { nxs_addToLogN('W', 'Skipped', '', 'Already Autoposted - Post ID:('.$postID.')' ); return; } $snap_isEdIT = get_post_meta($postID, 'snapEdIT', true); if ($snap_isEdIT!='1') { $doPost = true; $exclCats = maybe_unserialize($options['exclCats']); $postCats = wp_get_post_categories($postID); foreach ($postCats as $pCat) { if ( (is_array($exclCats)) && in_array($pCat, $exclCats)) $doPost = false; else {$doPost = true; break;}} if (!$doPost) { nxs_addToLogN('I', 'Skipped', '', 'Non-Human Post - Category Excluded - Post ID:('.$postID.')' ); return; } } if ($options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types); //prr($nxsCPTSeld); if ($post->post_type == 'post'|| ($options['useForPages']=='1' && $post->post_type == 'page') || in_array($post->post_type, $post_types) && in_array($post->post_type, $nxsCPTSeld)) foreach ($nxs_snapAvNts as $avNt) { if (count($options[$avNt['lcode']])>0) { $clName = 'nxs_snapClass'.$avNt['code']; if ($isPost && isset($_POST[$avNt['lcode']])) $po = $_POST[$avNt['lcode']]; else { $po = get_post_meta($postID, 'snap'.$avNt['code'], true); $po = maybe_unserialize($po);} if (isset($po) && is_array($po)) $isPostMeta = true; else { $isPostMeta = false; $po = $options[$avNt['lcode']]; } delete_post_meta($postID, 'snap_isAutoPosted'); add_post_meta($postID, 'snap_isAutoPosted', '1'); $optMt = $options[$avNt['lcode']][0]; if ($isPostMeta) { $ntClInst = new $clName(); $optMt = $ntClInst->adjMetaOpt($optMt, $po[0]); } if ($snap_isEdIT!='1') { $doPost = true; if ( $optMt['catSel']=='1' && trim($optMt['catSelEd'])!='' ) { $inclCats = explode(',',$optMt['catSelEd']); foreach ($postCats as $pCat) { if (!in_array($pCat, $inclCats)) $doPost = false; else {$doPost = true; break;}} if (!$doPost) { nxs_addToLogN('I', 'Skipped', $avNt['name'].' ('.$optMt['nName'].')', '[Non-Human Post] - Individual Category Excluded - Post ID:('.$postID.')' ); return; } } } if ($optMt['do'.$avNt['code']]=='1') { $optMt['ii'] = 0; if ($publtype=='A' && ($optMt['nMin']>0 || $optMt['nHrs']>0 || $optMt['nTime']!='')) $publtype='S'; if ($publtype=='S') { if (isset($optMt['nHrs']) && isset($optMt['nMin']) && ($optMt['nHrs']>0 || $optMt['nMin']>0) ) { $delay = $optMt['nMin']*60+$optMt['nHrs']*3600; nxs_addToLogN('I', 'Delayed', $avNt['name'].' ('.$optMt['nName'].')', 'Post has been delayed for '.$delay.' Seconds ('.($optMt['nHrs']>0?$optMt['nHrs'].' Hours':'')." ".($optMt['nMin']>0?$optMt['nMin'].' Minutes':'').')' ); } else $delay = rand(2,10); $optMt['timeToRun'] = time()+$delay; $args = array($postID, $optMt); wp_schedule_single_event($optMt['timeToRun'],'ns_doPublishTo'.$avNt['code'], $args); nxs_addToLogN('BI', 'Scheduled', $avNt['name'].' ('.$optMt['nName'].')', ' PostID:('.$postID.')' ); } else { $fname = 'nxs_doPublishTo'.$avNt['code']; $fname($postID, $optMt); } } else { nxs_addToLogN('GR', 'Skipped', $avNt['name'].' ('.$optMt['nName'].')', '-=[Unchecked Account]=- - PostID:'.$postID.'' ); } } } } if ($isS) restore_current_blog(); }} //## AJAX to Post to Google+ //## Add settings link to plugins list if (!function_exists("ns_add_settings_link")) { function ns_add_settings_link($links, $file) { static $this_plugin; if (!$this_plugin) $this_plugin = plugin_basename(__FILE__); if ($file == $this_plugin){ $settings_link = ''.__("Settings", "default").''; array_unshift($links, $settings_link); } return $links; }} //## Actions and filters if (!function_exists("ns_custom_types_setup")) { function ns_custom_types_setup(){ global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; $args=array('public'=>true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array(); if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator); if ( isset($options['nxsCPTSeld']) && $options['nxsCPTSeld']!='') $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array_keys($post_types); //prr($nxsCPTSeld); foreach ($post_types as $cptID=>$cptName) if (in_array($cptID, $nxsCPTSeld)){ // echo "|".$cptID."|"; add_action('future_to_publish_'.$cptID, 'nxs_snapPublishTo'); add_action('new_to_publish_'.$cptID, 'nxs_snapPublishTo'); add_action('draft_to_publish_'.$cptID, 'nxs_snapPublishTo'); add_action('pending_to_publish_'.$cptID, 'nxs_snapPublishTo'); add_action('private_to_publish_'.$cptID, 'nxs_snapPublishTo'); add_action('auto-draft_to_publish_'.$cptID, 'nxs_snapPublishTo'); } }} //## Process Spin if (!function_exists("nxs_spinRecursion")) { function nxs_spinRecursion(&$txt, $startCh) { global $nxs_spin_lCh, $nxs_spin_rCh, $nxs_spin_splCh; $startPos = $startCh; while ($startCh++ < strlen($txt)) { if (substr($txt, $startCh, strlen($nxs_spin_lCh)) == $nxs_spin_lCh) $txt = nxs_spinRecursion($txt, $startCh); elseif (substr($txt, $startCh, strlen($nxs_spin_rCh)) == $nxs_spin_rCh) { $tmpTxt = substr($txt, $startPos+strlen($nxs_spin_lCh), ($startCh - $startPos)-strlen($nxs_spin_rCh)); $toRepl = nxs_spinReplace($tmpTxt); $txt = str_replace($nxs_spin_lCh.$tmpTxt.$nxs_spin_rCh, $toRepl, $txt); } } return $txt; }} if (!function_exists("nxs_spinReplace")) { function nxs_spinReplace($txt) { global $nxs_spin_splCh; $txt = explode($nxs_spin_splCh, $txt); $out = $txt[mt_rand(0,count($txt)-1)]; return $out; }} if (!function_exists("nxs_doSpin")) { function nxs_doSpin($msg){ global $nxs_spin_lCh, $nxs_spin_rCh, $nxs_spin_splCh; $nxs_spin_lCh = '{'; $nxs_spin_rCh='}'; $nxs_spin_splCh='|'; $msg = nxs_spinRecursion($msg, -1); return $msg; }} //## Format Message if (!function_exists("nsFormatMessage")) { function nsFormatMessage($msg, $postID, $addURLParams=''){ global $ShownAds, $plgn_NS_SNAutoPoster, $nxs_urlLen; $post = get_post($postID); $options = $plgn_NS_SNAutoPoster->nxs_options; // if ($addURLParams=='' && $options['addURLParams']!='') $addURLParams = $options['addURLParams']; $msg = stripcslashes($msg); if (isset($ShownAds)) $ShownAdsL = $ShownAds; // $msg = htmlspecialchars(stripcslashes($msg)); $msg = nxs_doSpin($msg); if (preg_match('%URL%', $msg)) { $url = get_permalink($postID); if($addURLParams!='') $url .= (strpos($url,'?')!==false?'&':'?').$addURLParams; $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%URL%", $url, $msg);} if (preg_match('%SURL%', $msg)) { $url = get_permalink($postID); if($addURLParams!='') $url .= (strpos($url,'?')!==false?'&':'?').$addURLParams; $url = nxs_mkShortURL($url, $postID); $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%SURL%", $url, $msg); } if (preg_match('%IMG%', $msg)) { $imgURL = nxs_getPostImage($postID); $msg = str_ireplace("%IMG%", $imgURL, $msg); } if (preg_match('%TITLE%', $msg)) { $title = nxs_doQTrans($post->post_title, $lng); $msg = str_ireplace("%TITLE%", $title, $msg); } if (preg_match('%STITLE%', $msg)) { $title = nxs_doQTrans($post->post_title, $lng); $title = substr($title, 0, 115); $msg = str_ireplace("%STITLE%", $title, $msg); } if (preg_match('%AUTHORNAME%', $msg)) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun ); $msg = str_ireplace("%AUTHORNAME%", $aun, $msg);} if (preg_match('%ANNOUNCE%', $msg)) { $postContent = nxs_doQTrans($post->post_content, $lng); if (stripos($postContent, '')!==false) { $postContentEx = explode('',$postContent); $postContent = $postContentEx[0]; } elseif (stripos($postContent, '<!--more-->')!==false) { $postContentEx = explode('<!--more-->',$postContent); $postContent = $postContentEx[0]; } else $postContent = nsTrnc($postContent, $options['anounTagLimit']); $msg = str_ireplace("%ANNOUNCE%", $postContent, $msg); } if (preg_match('%TEXT%', $msg)) { if ($post->post_excerpt!="") $excerpt = apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)); else $excerpt= apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)); $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%TEXT%", $excerpt, $msg); } if (preg_match('%EXCERPT%', $msg)) { if ($post->post_excerpt!="") $excerpt = apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)); else $excerpt= apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)); $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%EXCERPT%", $excerpt, $msg); } if (preg_match('%RAWEXTEXT%', $msg)) { if ($post->post_excerpt!="") $excerpt = nxs_doQTrans($post->post_excerpt, $lng); else $excerpt= nxs_doQTrans($post->post_content, $lng); $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%RAWEXTEXT%", $excerpt, $msg); } if (preg_match('%RAWEXCERPT%', $msg)) { if ($post->post_excerpt!="") $excerpt = nxs_doQTrans($post->post_excerpt, $lng); else $excerpt= nxs_doQTrans($post->post_content, $lng); $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%RAWEXCERPT%", $excerpt, $msg); } if (preg_match('%TAGS%', $msg)) { $t = wp_get_object_terms($postID, 'product_tag'); if ( empty($t) || is_wp_error($pt) || !is_array($t) ) $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(', ',$tggs); $msg = str_ireplace("%TAGS%", $tags, $msg); } if (preg_match('%CATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array(); foreach($t as $c){ $cat = get_category($c); $cats[] = str_ireplace('&','&',$cat->name); } $ctts = implode(', ',$cats); $msg = str_ireplace("%CATS%", $ctts, $msg); } if (preg_match('%HCATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array(); foreach($t as $c){ $cat = get_category($c); $cats[] = "#".trim(str_replace(' ','', str_replace(' ', '', trim(str_ireplace('&','',str_ireplace('&','',$cat->name)))))); } $ctts = implode(', ',$cats); $msg = str_ireplace("%HCATS%", $ctts, $msg); } if (preg_match('%HTAGS%', $msg)) { $t = wp_get_object_terms($postID, 'product_tag'); if ( empty($t) || is_wp_error($pt) || !is_array($t) ) $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = "#".trim(str_replace(' ','',preg_replace('/[^a-zA-Z0-9\p{L}\p{N}\s]/u', '', trim(ucwords(str_ireplace('&','',str_ireplace('&','',$tagA->name))))))); } $tags = implode(', ',$tggs); $msg = str_ireplace("%HTAGS%", $tags, $msg); } if (preg_match('%CF-[a-zA-Z0-9]%', $msg)) { $msgA = explode('%CF', $msg); $mout = ''; foreach ($msgA as $mms) { if (substr($mms, 0, 1)=='-' && stripos($mms, '%')!==false) { $mGr = CutFromTo($mms, '-', '%'); $cfItem = get_post_meta($postID, $mGr, true); $mms = str_ireplace("-".$mGr."%", $cfItem, $mms); } $mout .= $mms; } $msg = $mout; } if (preg_match('%FULLTEXT%', $msg)) { $postContent = apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)); $msg = str_ireplace("%FULLTEXT%", $postContent, $msg);} if (preg_match('%RAWTEXT%', $msg)) { $postContent = nxs_doQTrans($post->post_content, $lng); $msg = str_ireplace("%RAWTEXT%", $postContent, $msg);} if (preg_match('%SITENAME%', $msg)) { $siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $msg = str_ireplace("%SITENAME%", $siteTitle, $msg);} if (isset($ShownAds)) $ShownAds = $ShownAdsL; // FIX for the quick-adsense plugin return trim($msg); }} if (!function_exists("nxs_adminInitFunc")) { function nxs_adminInitFunc(){ global $plgn_NS_SNAutoPoster, $nxs_snapThisPageUrl, $pagenow, $nxs_isWPMU; $nxs_snapThisPageUrl = admin_url().($pagenow=='admin.php'?'network/':'').$pagenow.'?page=NextScripts_SNAP.php'; //## Javascript to Admin Panel if (( ($pagenow=='options-general.php'||$pagenow=='admin.php') && isset($_GET['page']) && $_GET['page']=='NextScripts_SNAP.php') ||$pagenow=='post.php'||$pagenow=='post-new.php'){add_action('admin_head', 'jsPostToSNAP'); add_action('admin_head', 'nxs_jsPostToSNAP2');} if (function_exists('nxsDoLic_ajax')) { add_action('wp_ajax_nxsDoLic', 'nxsDoLic_ajax'); } if (function_exists('nxs_getInitUCheck') && (isset($plgn_NS_SNAutoPoster))) { $options = $plgn_NS_SNAutoPoster->nxs_options; if (is_array($options) && count($options)>1) nxs_getInitUCheck($options); } }} if (!function_exists("nxs_adminInitFunc2")) { function nxs_adminInitFunc2(){ global $plgn_NS_SNAutoPoster, $nxs_snapThisPageUrl, $pagenow; $nxs_snapThisPageUrl = admin_url().($pagenow=='admin.php'?'network/':'').$pagenow.'?page=NextScripts_SNAP.php'; //## Add MEtaBox to Post Edit Page if (current_user_can("see_snap_box") || current_user_can("manage_options")) add_action('add_meta_boxes', array($plgn_NS_SNAutoPoster, 'NS_SNAP_addCustomBoxes')); }} function nxs_saveSiteSets_ajax(){ check_ajax_referer('nxssnap'); if ($_POST['sid']=='A'){ global $wpdb; $allBlogs = $wpdb->get_results("SELECT blog_id FROM wp_blogs where blog_id > 1"); foreach( $allBlogs as $aBlog ) { switch_to_blog($aBlog->blog_id); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); $options = $plgn_NS_SNAutoPoster->nxs_options; $options['suaMode'] = $_POST['sset']; update_option($plgn_NS_SNAutoPoster->dbOptionsName, $options); } } else { switch_to_blog($_POST['sid']); $plgn_NS_SNAutoPoster = new NS_SNAutoPoster(); $options = $plgn_NS_SNAutoPoster->nxs_options; $options['suaMode'] = $_POST['sset']; update_option($plgn_NS_SNAutoPoster->dbOptionsName, $options); // prr($plgn_NS_SNAutoPoster->dbOptionsName); prr($options); } } function nxs_start_ob(){ob_start( 'nxs_ogtgCallback' );} function nxs_end_flush_ob(){ob_end_flush();} function nxs_ogtgCallback($content){ global $post, $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; $ogimgs = array(); if (stripos($content, 'og:title')!==false) $ogOut = "\r\n"; else { $title = preg_match( '/(.*)<\/title>/', $content, $title_matches ); if ($title !== false && count( $title_matches) == 2 ) $ogT ='<meta property="og:title" content="' . $title_matches[1] . '" />'."\r\n"; else { if (is_home() || is_front_page() ) $ogT = get_bloginfo( 'name' ); else $ogT = get_the_title(); $ogT = '<meta property="og:title" content="' . esc_attr( apply_filters( 'nxsog_title', $ogT ) ) . '" />'."\r\n"; } $decsription = preg_match( '/<meta name="description" content="(.*)"/', $content, $description_matches ); if ( $description !== false && count( $description_matches ) == 2 ) $ogD = '<meta property="og:description" content="' . $description_matches[1] . '" />'."\r\n"; { if (is_singular()) { if(has_excerpt($post->ID))$ogD=strip_tags(nxs_snapCleanHTML(get_the_excerpt($post->ID)));else $ogD= str_replace(" ", ' ', str_replace("\r\n", ' ', trim(substr(strip_tags(nxs_snapCleanHTML(strip_shortcodes($post->post_content))), 0, 200)))); } else $ogD = get_bloginfo('description'); $ogD = preg_replace('/\r\n|\r|\n/m','',$ogD); $ogD = '<meta property="og:description" content="'.esc_attr( apply_filters( 'nxsog_desc', $ogD ) ).'" />'."\r\n"; } $ogSN = '<meta property="og:site_name" content="'.get_bloginfo('name').'" />'."\r\n"; $ogLoc = strtolower(esc_attr(get_locale())); if (strlen($ogLoc)==2) $ogLoc .= "_".strtoupper($ogLoc); $ogLoc = '<meta property="og:locale" content="'.$ogLoc.'" />'."\r\n"; $iss = is_home(); $ogType = is_singular()?'article':'website'; if($vidsFromPost == false) $ogType = '<meta property="og:type" content="'.esc_attr(apply_filters('nxsog_type', $ogType)).'" />'."\r\n"; if (is_home() || is_front_page()) $ogUrl = get_bloginfo( 'url' ); else $ogUrl = 'http' . (is_ssl() ? 's' : '') . "://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $ogUrl = '<meta property="og:url" content="'.esc_url( apply_filters( 'nxsog_url', $ogUrl ) ) . '" />' . "\r\n"; if (!is_home()) { /* $vidsFromPost = nsFindVidsInPost($post); if ($vidsFromPost !== false && is_singular()) { echo '<meta property="og:video" content="http://www.youtube.com/v/'.$vidsFromPost[0].'" />'."\n"; echo '<meta property="og:video:type" content="application/x-shockwave-flash" />'."\n"; echo '<meta property="og:video:width" content="480" />'."\n"; echo '<meta property="og:video:height" content="360" />'."\n"; echo '<meta property="og:image" content="http://i2.ytimg.com/vi/'.$vidsFromPost[0].'/mqdefault.jpg" />'."\n"; echo '<meta property="og:type" content="video" />'."\n"; } */ if (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) { $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail' ); $ogimgs[] = $thumbnail_src[0]; } $imgsFromPost = nsFindImgsInPost($post, (int)$options['advFindOGImg']==1); if ($imgsFromPost !== false && is_singular() && is_array($ogimgs) && is_array($imgsFromPost)) $ogimgs = array_merge($ogimgs, $imgsFromPost); } //## Add default image to the endof the array if ( count($ogimgs)<1 && isset($options['ogImgDef']) && $options['ogImgDef']!='') $ogimgs[] = $options['ogImgDef']; //## Output og:image tags if (!empty($ogimgs) && is_array($ogimgs)) foreach ($ogimgs as $ogimage) $ogImgsOut = '<meta property="og:image" content="'.esc_url(apply_filters('ns_ogimage', $ogimage)).'" />'."\r\n"; $ogOut = "\r\n".$ogSN.$ogT.$ogD.$ogType.$ogUrl.$ogLoc.$ogImgsOut; } $content = str_ireplace('<!-- ## NXSOGTAGS ## -->', $ogOut, $content); return $content; } function nxs_addOGTagsPreHolder() { echo "<!-- ## NXS/OG ## --><!-- ## NXSOGTAGS ## --><!-- ## NXS/OG ## -->\n\r";} if (!function_exists("nxssnap_enqueue_scripts")) { function nxssnap_enqueue_scripts(){ wp_enqueue_script( 'nxssnap-scripts', plugin_dir_url( __FILE__ ) . 'js/js.js', array( 'jquery' ) ); wp_localize_script( 'nxssnap-scripts', 'MyAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nxsnapWPnonce' => wp_create_nonce( 'nxsnapWPnonce' ),)); }} if (!function_exists("nxs_getExpSettings_ajax")) { function nxs_getExpSettings_ajax() { check_ajax_referer('nsDN'); $filename = preg_replace('/[^a-z0-9\-\_\.]/i','',$_POST['filename']); header("Cache-Control: "); header("Content-type: text/plain"); header('Content-Disposition: attachment; filename="'.$filename.'"'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options; echo serialize($options); die(); }} //## Actions and filters if (isset($plgn_NS_SNAutoPoster)) { //## Actions //## Add the admin menu if ($nxs_isWPMU) add_action('network_admin_menu', 'nxs_AddSUASettings'); $suOptions = array(); $suOptions = $plgn_NS_SNAutoPoster->nxs_options; if ($nxs_isWPMU) { $ntOptions = $plgn_NS_SNAutoPoster->nxs_ntoptions; if (!isset($suOptions['suaMode'])) $suOptions['suaMode'] = ''; } $isPMB = $nxs_isWPMU && function_exists('nxs_doSMAS1') && $blog_id==1; $isO = !$nxs_isWPMU || ($nxs_isWPMU && ($suOptions['isMU']||$suOptions['isMUx']) && ($suOptions['suaMode']=='O' || ($suOptions['suaMode']=='' && $ntOptions['nxsSUType']=='O'))); $isS = !$nxs_isWPMU || ($nxs_isWPMU && ($suOptions['isMU']||$suOptions['isMUx']) && ($suOptions['suaMode']=='S' || ($suOptions['suaMode']=='' && $ntOptions['nxsSUType']=='S'))); if ($nxs_isWPMU) { if ($isO) $nxs_tpWMPU = 'O'; elseif ($isS) $nxs_tpWMPU = 'S';} // prr($nxs_tpWMPU); prr($suOptions); if (function_exists('nxs_doSMAS3')) nxs_doSMAS3($isS, $isO); if (!$isO && !$isS && !$isPMB) add_action('admin_menu', 'NS_SNAutoPoster_apx'); add_action('admin_init', 'nxs_adminInitFunc'); add_action( 'admin_enqueue_scripts', 'nxssnap_enqueue_scripts' ); add_action('wp_ajax_nxscr', 'nxscr_ajax'); add_action('wp_ajax_nxs_clLgo', 'nxs_clLgo_ajax'); add_action('wp_ajax_nxs_rfLgo', 'nxs_rfLgo_ajax'); add_action('wp_ajax_nxs_prxTest', 'nxs_prxTest_ajax'); add_action('wp_ajax_nxs_prxGet', 'nxs_prxGet_ajax'); add_action('wp_ajax_nxs_getExpSettings', 'nxs_getExpSettings_ajax'); add_action('wp_ajax_nxs_hideTip', 'nxs_hideTip_ajax'); add_action('nxs_hourly_event', 'nxs_do_this_hourly'); add_action('wp', 'nxs_activation'); add_action('shutdown', 'nxs_psCron'); if ($isO || $isS) { //## Whenever you publish a post, post to Social Networks add_action('future_to_publish', 'nxs_snapPublishTo'); add_action('new_to_publish', 'nxs_snapPublishTo'); add_action('draft_to_publish', 'nxs_snapPublishTo'); add_action('pending_to_publish', 'nxs_snapPublishTo'); add_action('private_to_publish', 'nxs_snapPublishTo'); add_action('auto-draft_to_publish', 'nxs_snapPublishTo'); //## Add nxs_snapPublishTo to custom post types add_action('wp_loaded', 'ns_custom_types_setup' ); foreach ($nxs_snapAvNts as $avNt) { add_action('ns_doPublishTo'.$avNt['code'], 'nxs_doPublishTo'.$avNt['code'], 1, 2); } foreach ($nxs_snapAvNts as $avNt) { add_action('wp_ajax_rePostTo'.$avNt['code'], 'nxs_rePostTo'.$avNt['code'].'_ajax'); } //## Add AJAX Calls for Test and Repost add_action('wp_ajax_getBoards' , 'nsGetBoards_ajax'); add_action('wp_ajax_getGPCats' , 'nsGetGPCats_ajax'); add_action('wp_ajax_getWLBoards' , 'nsGetWLBoards_ajax'); add_action('wp_ajax_nsDN', 'ns_delNT_ajax'); } if ($isO) { add_action('admin_menu', 'NS_SNAutoPoster_ap'); add_action('admin_init', 'nxs_adminInitFunc2'); //## Initialize options on plugin activation $myrelpath = preg_replace( '/.*wp-content.plugins./', '', __FILE__ ); add_action("activate_".$myrelpath, array(&$plgn_NS_SNAutoPoster, 'init')); //## Add/Change meta on Save add_action('edit_post', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags')); add_action('publish_post', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags')); add_action('save_post', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags')); add_action('edit_page_form', array($plgn_NS_SNAutoPoster, 'NS_SNAP_SavePostMetaTags')); add_action('wp_ajax_nsAuthFBSv', 'nsAuthFBSv_ajax'); //## Custom Post Types and OG tags add_filter('plugin_action_links','ns_add_settings_link', 10, 2 ); add_filter('get_avatar','ns_get_avatar', 10, 5 ); //## Scedulled Publish Calls if ((int)$suOptions['nsOpenGraph'] == 1) { add_action( 'init', 'nxs_start_ob', 0 ); add_action( 'wp_footer', 'nxs_end_flush_ob', 10000 ); add_action('wp_head', 'nxs_addOGTagsPreHolder', 150); } } if ($nxs_isWPMU){ if (function_exists('nxssnapmu_columns_head')) add_filter('wpmu_blogs_columns', 'nxssnapmu_columns_head'); if (function_exists('nxssnapmu_columns_content')) add_action('manage_blogs_custom_column', 'nxssnapmu_columns_content', 10, 2); if (function_exists('nxssnapmu_columns_content')) add_action('manage_sites_custom_column', 'nxssnapmu_columns_content', 10, 2); if (function_exists('nxs_add_style')) add_action( 'admin_footer', 'nxs_add_style' ); if (function_exists('nxs_saveSiteSets_ajax')) add_action('wp_ajax_nxs_saveSiteSets', 'nxs_saveSiteSets_ajax'); } } ?>