Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
Understanding Blog Linking
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
Offline
May 20, 2017 - 12:32 am

Happy to help too. Hope to try the basics soon. Just bad timing with Andy on vacation and me moving this weekend. 

Avatar
Chris_Andrews
Member
Offline
May 20, 2017 - 11:35 am

Moving, what fun! I've been doing a lot of that over the last 6 months, our house was totaled in hurricane matthew and we are rebuilding. Both moving ourselves and helping friends. If I was in your area I'd be happy to come help there too 🙂 

Looking at the code, but not really familiar with hooks and all, it seems like I should be able to temporarily hack sp-linking-support.php and do something like this to add my old posts in with the original publication dates:

Didn't work though...

////////////////////////////////////

function sp_do_linking_update_blog_post($newpost) {
global $wpdb;
$ID = sp_esc_int($newpost['blogpostid']);
$postcontent = $newpost['postcontent']; # it comes here already filtered
spdb_query("UPDATE ".$wpdb->prefix."posts SET post_content = '$postcontent'

//post_date = the_date() //didn't work
//post_date = '2016-05-20 11:05:19' //for testing, didn't work

WHERE ID = $ID"); }

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
Offline
May 20, 2017 - 2:58 pm

well, that couldnt work, because its updating a linked forum topic... in your case, the topic doesnt exist yet..  you would want the routine where the topic is created...  that would be sp_publish_blog_link()...

then in that routine, use the $post->post_date or $post->post_date_gmt to get the blog post date...  and then try setting $p->newpost['post_date'] equal to that blog post date...  if your timezone matches the server timezone, think the dates will be fine... but have not tried this...

Avatar
Chris_Andrews
Member
Offline
May 21, 2017 - 7:50 pm

Sorry, it's over my head...

Do you mean something like this? 

 ---------

$p->newpost['forumid'] = $forumid;
$p->newpost['forumslug'] = $forumslug;
$p->newpost['topicname'] = sp_filter_title_save($post->post_title, SFTOPICS, 'topic_name');
//added
$p->newpost['post_date'] = $post->post_date;

 ---------

That didn't seem to make it into the sql, still uses current date...

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
Offline
May 22, 2017 - 9:33 am

will try to look further tonight (but moving to new house so may be hard)...  I think you want to do the setting of the date later...  in its own query..  or just before the saveData call for the post class...

Avatar
Chris_Andrews
Member
Offline
May 23, 2017 - 11:29 am

Well, I can add an sql statement under the SaveData part to give it a date: 

$sql = "UPDATE wp_sfposts SET post_date = ".$p->newpost['post_date']." WHERE topic_id = ".$p->newpost['topicid'];

But I'm having trouble getting the $p->newpost['post_date'] value. I can hard code a date in there and it works, but I haven't been able to figure out how to get that date in the code,

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
Offline
May 23, 2017 - 8:47 pm

sorry, not sure I follow...  seems you are saying that line of code works, but you cant get the $p->newpost[‘post_date’] value???  which seems to conflict with it working...  can you explain what code you have that is not working?

Avatar
Chris_Andrews
Member
Offline
May 23, 2017 - 9:33 pm

Sorry I was unclear -  🙂 

If I do this: 

$sql = “UPDATE wp_sfposts SET post_date = “2016-06-26 11:02:4” WHERE topic_id = “.$p->newpost[‘topicid’];

I get that date into the database, so I know the sql works. 

I think I probably need to put this (or something else?): 

$p->newpost[‘post_date’] = $post->post_date; 

in before that, but I haven't figured out what and where, so that the date that is on the original post is used.

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
Offline
May 23, 2017 - 10:35 pm

ah, I understand...  you cannot reference $post in that routine as it doesnt exist in the scope...  I had intended for you to put the code in the blog linking plugin itself AFTER the call to saveData...

looking at this a bit more, might need a bit more magic too...  

before:

$p->saveData();

add

add_action('sph_new_post', 'my_linking_code'); 
function my_linking_code($newpost) { 
global $spVars; 
$spVars['linkedpost'] = $newpost['postid']; 
}

and then after this:

$sql = "UPDATE ".SFTOPICS." SET blog_post_id = ".$post->ID." WHERE topic_id = ".$p->newpost['topicid'];
spdb_query($sql);

add:

$sql = "UPDATE ".SFPOSTS." SET post_date = ".$post->post_date." WHERE post_id = ".$sfVars['linkedpost'];
spdb_query($sql);

still untested... 🙁

Avatar
Chris_Andrews
Member
Offline
May 26, 2017 - 10:46 pm

Alas, still getting today's date. 

Sorry it took me a bit to get back to you on this. 

***
News For Shoppers is seeking consumer reporters,
consumer advocates, and entertainment writers:
visit: NewsForShoppers.com/write/

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17362
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625