} } if (!$tableExist) { $sql = "CREATE TABLE " . $wpdb->prefix . WSO_DB_LOG . " (\r\n\t\t\t`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\n\t\t\t`blog_id` INT NOT NULL ,\r\n\t\t\t`time` DATETIME NOT NULL ,\r\n\t\t\t`message` text NOT NULL\r\n\t\t\t) ENGINE = MYISAM ;"; $wpdb->query($sql); } } add_action('save_post', 'wso_save_post', 1); function wso_save_post($postid) { // ONLY FOR Press This !! if (isset($_POST['press-this']) && wp_verify_nonce($_POST['press-this'], 'press-this')) { wso_publish_post($postid); } } $types = wso_get_post_types(); foreach ($types as $type => $whatever) { add_action('publish_' . $type, 'wso_publish_post', 99); } function wso_publish_post($postid) { global $wso_services; $wsoOpts = get_option(WSO_OPTIONS); // Must Publish ? $mustPublish = array(); foreach ($wso_services as $servAbbr => $serv) { $mustPublish[$servAbbr] = isset($_POST['post_wso_' . $servAbbr]) ? 1 : 0; } $countMustPublish = array_count_values($mustPublish); if (isset($countMustPublish[1]) && $countMustPublish[1] > 0) { $_wso_opts = get_post_meta($postid, '_wso_opts', true);
public function showPage() { $wsoOpts = get_option(WSO_OPTIONS); if (!isset($wsoOpts[$this->m_options['access_token']])) { $urlPlugin = urlencode(get_bloginfo('wpurl') . "/wp-admin/options-general.php?page=wordsocial"); echo '<p>' . _e('If you want to auto-publish your blog posts/pages on your facebook wall (or on the wall of your fanpages), you have to connect to your FB account', 'wordsocial') . '</p>'; echo '<p><a href="http://wso.li/iconnectFb.php?login&r=' . $urlPlugin . '"><img height="21" width="169" src="' . WSO_IMAGES_FOLDER . 'signin-facebook.gif" alt="signin facebook" /></a></p>'; } else { $user = $this->authenticate(); $opts = explode("|", $wsoOpts[$this->m_options['options']]); // select account $msgAccountsSelect = __('Choose the page on which you would like to publish your posts', 'wordsocial'); $accountsSelect = "<option value='-1' " . (in_array($wsoOpts[$this->m_options['access_token']], $wsoOpts[$this->m_options['pages_access_token']]) ? " selected='selected'" : '') . ">" . $user['name'] . " (My Wall)</option>"; foreach ($this->m_fbAccounts['data'] as $k => $v) { $sel = in_array($v['access_token'], $wsoOpts[$this->m_options['pages_access_token']]) ? ' selected="selected"' : ''; $accountsSelect .= "<option value='{$k}' {$sel}>{$v['name']} ({$v['category']})</option>"; } $types = wso_get_post_types(); ?> <p><?php _e('Hello', 'wordsocial'); ?> <strong><?php echo $user['name']; ?> </strong>. <a href="options-general.php?page=wordsocial&disconnect=fb">[<?php _e('Disconnect', 'wordsocial'); ?> ]</a></p> <table class="form-table"> <tbody> <tr> <th><?php _e('Choose the page on which you would like to publish your posts', 'wordsocial'); ?> </th> <td> <select name="wsofb_access_token[]" id="wsofbat" multiple="multiple" size="5" style="height: auto;"><?php echo $accountsSelect; ?> </select> </td> </tr> <?php $types = wso_get_post_types(); $i = self::WSO_OPT_START_CUSTOM_TYPE; foreach ($types as $type => $label) { echo "<tr>"; echo "\t<th>" . sprintf(__('Publish "%s" by default', 'wordsocial'), $label) . "</th>"; echo "\t<td>"; echo "\t\t<input type='radio' value='1' name='wsofbpublish[{$type}]' id='wsofbenable{$i}'" . ((int) $opts[$i] == 1 ? ' checked="checked"' : '') . " /> <label for='wsofbenable{$i}'>" . __('Yes', 'wordsocial') . "</label> <input type='radio' value='0' name='wsofbpublish[{$type}]' id='wsofbdisable{$i}'" . ((int) $opts[$i] == 0 ? ' checked="checked"' : '') . " /> <label for='wsofbdisable{$i}'>" . __('No', 'wordsocial') . "</label>"; echo "\t</td>"; echo "</tr>"; ++$i; } ?> <tr> <th><?php _e('Show an image ?', 'wordsocial'); ?> </th> <td> <input type="radio" value="1" name="wsofb_showpicture" id="wsofb_show_picture"<?php echo (int) $opts[self::WSO_OPT_PICTURE] == 1 ? ' checked="checked"' : ''; ?> /> <label for="wsofb_show_picture"><?php _e('Yes', 'wordsocial'); ?> </label> <input type="radio" value="0" name="wsofb_showpicture" id="wsofb_hide_picture"<?php echo (int) $opts[self::WSO_OPT_PICTURE] == 0 ? ' checked="checked"' : ''; ?> /> <label for="wsofb_hide_picture"><?php _e('No', 'wordsocial'); ?> </label> </td> </tr> </tbody> </table> <?php } }
public function showPage() { $wsoOpts = get_option(WSO_OPTIONS); if (!isset($wsoOpts[$this->m_options['access_token']])) { echo '<p>' . _e('If you want to auto-publish your blog posts/pages on your Twitter account, you have to authorize WordSocial to publish on it', 'wordsocial') . '</p>'; echo '<p><a href="options-general.php?page=wordsocial&connect=tw"><img height="16" width="136" src="' . WSO_IMAGES_FOLDER . 'signin-twitter.png" alt="signin twitter" /></a></p>'; } else { $user = $this->authenticate(); $opts = explode("|", $wsoOpts[$this->m_options['options']]); ?> <p><?php _e('Hello', 'wordsocial'); ?> <strong><?php echo $user->screen_name; ?> </strong>. <a href="options-general.php?page=wordsocial&disconnect=tw">[<?php _e('Disconnect', 'wordsocial'); ?> ]</a></p> <table class="form-table"> <tbody> <?php $types = wso_get_post_types(); $i = self::WSO_OPT_START_CUSTOM_TYPE; foreach ($types as $type => $label) { echo "<tr>"; echo "\t<th>" . sprintf(__('Publish "%s" by default', 'wordsocial'), $label) . "</th>"; echo "\t<td>"; echo "\t\t<input type='radio' value='1' name='wsotwpublish[{$type}]' id='wsotwenable{$i}'" . ((int) $opts[$i] == 1 ? ' checked="checked"' : '') . " /> <label for='wsotwenable{$i}'>" . __('Yes', 'wordsocial') . "</label> <input type='radio' value='0' name='wsotwpublish[{$type}]' id='wsotwdisable{$i}'" . ((int) $opts[$i] == 0 ? ' checked="checked"' : '') . " /> <label for='wsotwdisable{$i}'>" . __('No', 'wordsocial') . "</label>"; echo "\t</td>"; echo "</tr>"; ++$i; } ?> <tr> <th><?php _e('Use post categories as #hashtags ?', 'wordsocial'); ?> </th> <td> <input type='radio' value='1' name='wsotwhashtagscat' id='wsotwhashtagscatYes'<?php echo (int) $opts[self::WSO_OPT_CATEGORIES_AS_HASHTAGS] == 1 ? ' checked="checked"' : ''; ?> /> <label for='wsotwhashtagscatYes'><?php _e('Yes', 'wordsocial'); ?> </label> <input type='radio' value='0' name='wsotwhashtagscat' id='wsotwhashtagscatNo'<?php echo (int) $opts[self::WSO_OPT_CATEGORIES_AS_HASHTAGS] == 0 ? ' checked="checked"' : ''; ?> /> <label for='wsotwhashtagscatNo'><?php _e('No', 'wordsocial'); ?> </label> </td> </tr> <tr> <th><?php _e('Use post tags as #hashtags ?', 'wordsocial'); ?> </th> <td> <input type='radio' value='1' name='wsotwhashtagstags' id='wsotwhashtagstagsYes'<?php echo (int) $opts[self::WSO_OPT_TAGS_AS_HASHTAGS] == 1 ? ' checked="checked"' : ''; ?> /> <label for='wsotwhashtagstagsYes'><?php _e('Yes', 'wordsocial'); ?> </label> <input type='radio' value='0' name='wsotwhashtagstags' id='wsotwhashtagstagsNo'<?php echo (int) $opts[self::WSO_OPT_TAGS_AS_HASHTAGS] == 0 ? ' checked="checked"' : ''; ?> /> <label for='wsotwhashtagstagsNo'><?php _e('No', 'wordsocial'); ?> </label> </td> </tr> <tr> <th><label for="wsotwfmt"><?php _e('Tweet format :', 'wordsocial'); ?> </label></th> <td> <input type="text" style="width: 100%" value="<?php echo stripslashes($wsoOpts[$this->m_options['format']]); ?> " name="wsotwfmt" id="wsotwfmt" /> <p>%title : <?php _e('Post title', 'wordsocial'); ?> <br/> %link : <?php _e('Link to the post', 'wordsocial'); ?> <br/> %excerpt : <?php _e('Excerpt from the post', 'wordsocial'); ?> <br/> %comment : <?php _e('A comment (you write the comment into the post editor)', 'wordsocial'); ?> <br/> %categories : <?php _e('Use the post categories as #hashtags', 'wordsocial'); ?> <br/> %tags : <?php _e('Use the post tags as #hashtags', 'wordsocial'); ?> <br/></p> </td> </tr> <tr> <th><?php _e('Shortening method for the link:', 'wordsocial'); ?> </th> <td> <select name="wsotwwsourl" id="wsotwwsourl"> <option value="bitly"<?php echo $wsoOpts[$this->m_options['short_method']] == "bitly" ? 'selected="selected"' : ''; ?> >bit.ly</option> <option value="obitly"<?php echo $wsoOpts[$this->m_options['short_method']] == "obitly" ? 'selected="selected"' : ''; ?> ><?php _e('Your own bit.ly configuration', 'wordsocial'); ?> </option> <option value="wso"<?php echo $wsoOpts[$this->m_options['short_method']] == "wso" ? 'selected="selected"' : ''; ?> >wso.li</option> <option value="yourls"<?php echo $wsoOpts[$this->m_options['short_method']] == "yourls" ? 'selected="selected"' : ''; ?> ><?php _e('Your own YOURLS configuration', 'wordsocial'); ?> </option> </select><br /> <div id="wso_yourls"> <?php _e('URL Yourls:', 'wordsocial'); ?> <input type="text" name="wso_yourls_url" value="{$wsoOpts['wsourlp'][0]}" /> (http://your-domain.com/yourls-api.php)<br /> <?php _e('Signature:', 'wordsocial'); ?> <input type="text" name="wso_yourls_sign" value="{$wsoOpts['wsourlp'][1]}" /><br /> </div> <div id="wso_obitly"> <?php _e('Login Bit.ly:', 'wordsocial'); ?> <input type="text" name="wso_obitly_login" value="{$wsoOpts['wsourlp'][0]}" /><br /> <?php _e('API Key:', 'wordsocial'); ?> <input type="text" name="wso_obitly_apikey" value="{$wsoOpts['wsourlp'][1]}" /> </div> <script type="text/javascript"> <?php echo $wsoOpts[$this->m_options['short_method']] != "yourls" ? "jQuery('#wso_yourls').hide();" : ''; ?> <?php echo $wsoOpts[$this->m_options['short_method']] != "obitly" ? "jQuery('#wso_obitly').hide();" : ''; ?> jQuery('#wsotwwsourl').change(function(){ var value = jQuery(this).val(); if(value == "yourls") { jQuery('#wso_yourls').show(); jQuery('#wso_obitly').hide(); } else if(value == "obitly") { jQuery('#wso_obitly').show(); jQuery('#wso_yourls').hide(); } else { jQuery('#wso_yourls').hide(); jQuery('#wso_obitly').hide(); } }); </script> </td> </tr> </tbody> </table> <?php } }
function wso_add_meta_boxes() { $pp = wso_get_post_types(); foreach ($pp as $p => $whatever) { add_meta_box('wso_wordsocial', __('WordSocial', 'wordsocial'), 'wso_inner_meta_boxes', $p, 'side', 'core'); } }
public function showPage() { $wsoOpts = get_option(WSO_OPTIONS); if (!isset($wsoOpts[$this->m_options['access_token']])) { echo '<p>' . _e('If you want to auto-publish your blog posts/pages on your LinkedIn, you have to connect to your account.', 'wordsocial') . '</p>'; echo '<p><a href="options-general.php?page=wordsocial&connect=li"><img height="21" width="133" src="' . WSO_IMAGES_FOLDER . 'signin-linkedin.png" alt="signin linkedin" /></a></p>'; } else { $user = $this->authenticate(); $opts = explode("|", $wsoOpts[$this->m_options['options']]); ?> <p><?php _e('Hello', 'wordsocial'); ?> <strong><?php echo $user; ?> </strong>. <a href="options-general.php?page=wordsocial&disconnect=li">[<?php _e('Disconnect', 'wordsocial'); ?> ]</a></p> <table class="form-table"> <tbody> <?php $types = wso_get_post_types(); $i = self::WSO_OPT_PICTURE + 1; foreach ($types as $type => $label) { echo "<tr>"; echo "\t<th>" . sprintf(__('Publish "%s" by default', 'wordsocial'), $label) . "</th>"; echo "\t<td>"; echo "\t\t<input type='radio' value='1' name='wsolipublish[{$type}]' id='wsolienable{$i}'" . ((int) $opts[$i] == 1 ? ' checked="checked"' : '') . " /> <label for='wsolienable{$i}'>" . __('Yes', 'wordsocial') . "</label> <input type='radio' value='0' name='wsolipublish[{$type}]' id='wsolidisable{$i}'" . ((int) $opts[$i] == 0 ? ' checked="checked"' : '') . " /> <label for='wsolidisable{$i}'>" . __('No', 'wordsocial') . "</label>"; echo "\t</td>"; echo "</tr>"; ++$i; } ?> <tr> <th><?php _e('Show an image ?', 'wordsocial'); ?> </th> <td> <input type="radio" value="1" name="wsoli_showpicture" id="wsoli_show_picture"<?php echo (int) $opts[self::WSO_OPT_PICTURE] == 1 ? ' checked="checked"' : ''; ?> /> <label for="wsoli_show_picture"><?php _e('Yes', 'wordsocial'); ?> </label> <input type="radio" value="0" name="wsoli_showpicture" id="wsoli_hide_picture"<?php echo (int) $opts[self::WSO_OPT_PICTURE] == 0 ? ' checked="checked"' : ''; ?> /> <label for="wsoli_hide_picture"><?php _e('No', 'wordsocial'); ?> </label> </td> </tr> </tbody> </table> <?php } }