Hacking an existing plugin: modifying a string?
-
I’m trying to hack the JournalPress plugin, which hasn’t been updated in something like two years, so I can’t really expect any support on that end.
FYI, JournalPress is a crossposting plugin, which I use to crosspost to my LiveJournal. My issue is that I keep all the important content to be crossposted in a variety of custom fields using a custom panel developed in Magic Fields. I never enter any data in the_content if I can help it. JournalPress, obviously, is specifically designed to crosspost the_content.
I need to hack the plugin to declare that a series of custom taxonomies and fields are to be crossposted instead.
Here are what I assume are the relevant bits of code I should be paying attention to.
journalpress/lj.class.php
$params = array( "username" => $this->lj_userid, "auth_method" => 'challenge', "auth_challenge" => $this->lj_challenge, "auth_response" => md5( $this->lj_challenge . $this->lj_md5pwd ), "ver" => $this->protocol_version, "lineendings" => $this->lineendings, "itemid" => $jdata['itemid'], "subject" => $jdata['subject'], "event" => $jdata['event'], "year" => $jdata['year'], "mon" => $jdata['mon'], "day" => $jdata['day'], "hour" => $jdata['hour'], "min" => $jdata['min'], "security" => $jdata['security'], "allowmask" => $jdata['allowmask'], "props" => $jmeta );
"subject" => $jdata['subject'],
is the important bit.journalpress/jpfunctions.php
// The filters run the WP texturization - cleans up the code $jdata['event'] = $the_event; $jdata['subject'] = apply_filters( 'the_title', $p->post_title );
I have successfully modified this bit of code to make the contents of one of my custom taxonomies crosspost with
$the_event
:// The filters run the WP texturization - cleans up the code $jp_custom_taxonomy = get_the_term_list( $p->ID, 'custom_taxonomy', '', ', ', '' ) ; $jdata['event'] = strip_tags($jp_custom_taxonomy).''.$the_event; $jdata['subject'] = apply_filters( 'the_title', $p->post_title );
Alas, I cannot add if/else statements to this particular line of code and the display I require needs an assortment of if/else statements.
I’m self-taught through trial and error when it comes to php, so I still have a lot to learn and my coding vocabulary is somewhat limited. I presume
$jdata['event'] = $the_event;
is called a string declaration? And if statements cannot be declared in a string? If that is true, there must be some sort of workaround? How do I add the results of if statements to the$jdata['event']
string?
- The topic ‘Hacking an existing plugin: modifying a string?’ is closed to new replies.