插件功能:A站发布文章,自动同步到B站,B站发布文章,也能同步到A站,甚至可以套娃同步到C到D。
这个插件我刚刚找到的,非常好用,支持任何主题文章同步。
![图片[1]-Sync Post:多站点文章发布自动同步插件【已更新汉化版】-回忆博客](https://img.meituan.net/portalweb/59d2ad01594d1527097301f2e5413b4929468.png)
By回忆博客 汉化:
<?php
global $sps, $sps_settings;
if( isset( $_REQUEST['sps_setting_save'] ) && isset( $_REQUEST['sps_setting'] ) && $_REQUEST['sps_setting'] != '' ) {
do_action( 'sps_save_settings', $_POST );
}
echo '<div class="wrap sps_content">';
if( isset($_SESSION['sps_msg_status']) && $_SESSION['sps_msg_status'] ) {
echo '<div id="message" class="updated notice notice-success is-dismissible">';
echo '<p>';
echo (isset($_SESSION['sps_msg']) && $_SESSION['sps_msg']!='') ? $_SESSION['sps_msg'] : '操作失败,请重试';
echo '</p>';
echo '<button type="button" class="notice-dismiss"><span class="screen-reader-text">关闭此提示</span></button>';
echo '</div>';
unset($_SESSION['sps_msg_status']);
unset($_SESSION['sps_msg']);
}
echo '<form name="sps_settings" id="sps_settings" method="post" >';
global $sps, $sps_settings;
wp_nonce_field('sps_nonce_action', 'sps_general_option_field');
$general_option = $sps_settings->sps_get_settings_func();
if(!empty($general_option)) {
$total_record = count($general_option['sps_host_name']);
$spcn = 0;
echo '<div class="cmrc-table">';
echo '<div class="setting-general" >';
echo '<h2>常规设置</h2>';
foreach ($general_option['sps_host_name'] as $sps_key => $sps_value) {
$sps_host_name = ($sps_value) ? $sps_value : '';
$sps_strict_mode = isset($general_option['sps_strict_mode'][$sps_key]) ? $general_option['sps_strict_mode'][$sps_key] : 1;
$sps_content_match = isset($general_option['sps_content_match'][$sps_key]) ? $general_option['sps_content_match'][$sps_key] : 'title';
$sps_roles_allowed = isset($general_option['sps_roles_allowed'][$sps_key]) ? $general_option['sps_roles_allowed'][$sps_key] : array();
$sps_contributor = isset($sps_roles_allowed['roles']['contributor']) ? $sps_roles_allowed['roles']['contributor'] : '';
$sps_author = isset($sps_roles_allowed['roles']['author']) ? $sps_roles_allowed['roles']['author'] : '';
$sps_editor = isset($sps_roles_allowed['roles']['editor']) ? $sps_roles_allowed['roles']['editor'] : '';
$sps_selected = isset($general_option['sps_selected'][$sps_key]) ? $general_option['sps_selected'][$sps_key] : '';
$sps_content_username = isset($general_option['sps_content_username'][$sps_key]) ? $general_option['sps_content_username'][$sps_key] : '';
$sps_content_password = isset($general_option['sps_content_password'][$sps_key]) ? $general_option['sps_content_password'][$sps_key] : '';
?>
<div class="remove_site_<?php echo $spcn; ?>">
<table class="form-table sps-setting-form count_table">
<tbody>
<tr>
<th><label for="sps_host_name_<?php echo $spcn; ?>">目标网站域名</label></th>
<td>
<input type="text" name="sps_host_name[<?php echo $spcn; ?>]" id="sps_host_name_<?php echo $spcn; ?>" class="sps_input sps_url" value="<?php echo sanitize_url($sps_host_name) ?>" />
<?php if($spcn!=0) { ?>
<a href="javascript:;" class="remove_site" data-site_id="<?php echo $spcn; ?>"> 删除站点 </a>
<?php } ?>
<p>格式:https://example.com - 这是内容将同步到的目标网址。如果WordPress安装在子目录,请包含子目录路径。</p>
</td>
</tr>
<tr>
<th><label for="sps_content_username_<?php echo $spcn; ?>">登录用户名</label></th>
<td>
<input type="text" name="sps_content_username[<?php echo $spcn; ?>]" id="sps_content_username_<?php echo $spcn; ?>" class="sps_input" value="<?php echo sanitize_user($sps_content_username) ?>" />
<p>请输入 <span class="sps_username"></span> 网站的登录用户名</p>
</td>
</tr>
<tr>
<th><label for="sps_content_password_<?php echo $spcn; ?>">登录密码</label></th>
<td>
<div class="sps_password_box">
<input type="password" name="sps_content_password[<?php echo $spcn; ?>]" id="sps_content_password_<?php echo $spcn; ?>" class="sps_input" value="<?php echo wp_strip_all_tags( stripslashes($sps_content_password) ) ?>" />
<span class="dashicons dashicons-visibility sps_show_pass"></span>
<span class="dashicons dashicons-hidden sps_hide_pass"></span>
</div>
<p>请输入 <span class="sps_password"></span> 网站的登录密码</p>
</td>
</tr>
<tr>
<th><label for="sps_strict_mode_<?php echo $spcn; ?>">严格模式</label></th>
<td>
<input <?php if($sps_strict_mode==1) { echo "checked='checked'"; } ?> type="radio" name="sps_strict_mode[<?php echo $spcn; ?>]" value="1" class="sps_radio" id="sps_strict_mode_on_<?php echo $spcn; ?>" >
<label for="sps_strict_mode_on_<?php echo $spcn; ?>"> 开启 - 源站和目标站的WordPress及插件版本必须一致才能执行同步操作。 </label>
<br>
<input <?php if($sps_strict_mode==0) { echo "checked='checked'"; } ?> type="radio" name="sps_strict_mode[<?php echo $spcn; ?>]" value="0" class="sps_radio" id="sps_strict_mode_off_<?php echo $spcn; ?>">
<label for="sps_strict_mode_off_<?php echo $spcn; ?>">关闭 - 源站和目标站的WordPress及插件版本无需一致。</label>
</td>
</tr>
<tr>
<th><label for="sps_content_match_<?php echo $spcn; ?>">内容匹配模式</label></th>
<td>
<select id="sps_content_match_<?php echo $spcn; ?>" name="sps_content_match[<?php echo $spcn; ?>]" class="sps_select">
<option <?php if($sps_content_match=='slug') { echo "selected"; } ?> value="slug">文章别名</option>
</select>
<p>文章别名 - 仅通过文章别名在目标站搜索匹配的内容。</p>
</td>
</tr>
<tr>
<th><label for="sps_roles_allowed_<?php echo $spcn; ?>">允许使用的用户角色</label></th>
<td>
<input <?php if($sps_contributor) { echo "checked"; } ?> type="checkbox" class="sps_checkbox" name="sps_roles_allowed[<?php echo $spcn; ?>][roles][contributor]" id="sps_roles_contributor_<?php echo $spcn; ?>" >
<label for="sps_roles_contributor_<?php echo $spcn; ?>">投稿者</label><br>
<input <?php if($sps_author) { echo "checked"; } ?> type="checkbox" class="sps_checkbox" name="sps_roles_allowed[<?php echo $spcn; ?>][roles][author]" id="sps_roles_author_<?php echo $spcn; ?>" >
<label for="sps_roles_author_<?php echo $spcn; ?>">作者</label><br>
<input <?php if($sps_editor) { echo "checked"; } ?> type="checkbox" class="sps_checkbox" name="sps_roles_allowed[<?php echo $spcn; ?>][roles][editor]" id="sps_roles_editor_<?php echo $spcn; ?>" >
<label for="sps_roles_editor_<?php echo $spcn; ?>">编辑</label><br>
<input type="checkbox" class="sps_checkbox" name="sps_roles_allowed[<?php echo $spcn; ?>][roles][administrator]" checked="checked" id="sps_roles_administrator_<?php echo $spcn; ?>" disabled="disabled">
<label for="sps_roles_administrator_<?php echo $spcn; ?>">管理员</label><br>
<p>选择允许使用文章同步功能的用户角色,仅选中的角色可执行同步操作。</p>
</td>
</tr>
<tr>
<th><label for="sps_selected_<?php echo $spcn; ?>">默认选中</label></th>
<td>
<input <?php if($sps_selected) { echo "checked"; } ?> type="checkbox" class="sps_checkbox" name="sps_selected[<?php echo $spcn; ?>]" id="sps_selected_<?php echo $spcn; ?>" />
<label for="sps_selected_<?php echo $spcn; ?>">在添加/编辑文章时自动选中该站点</label><br>
</td>
</tr>
</tbody>
</table>
<hr/>
</div>
<?php
$spcn++;
}
echo '<input type="hidden" id="auto_increment" value="'.$spcn.'">';
echo '</div>';
echo '</div>';
}
?>
<script id="sps_setting_table" type="text/html">
<div class="remove_site_{sps_no}">
<table class="form-table sps-setting-form count_table">
<tbody>
<tr>
<th><label for="sps_host_name_{sps_no}">目标网站域名</label></th>
<td>
<input type="text" name="sps_host_name[{sps_no}]" id="sps_host_name_{sps_no}" class="sps_input sps_url" />
<a href="javascript:;" class="remove_site" data-site_id="{sps_no}">删除站点</a>
<p>格式:https://example.com - 这是内容将同步到的目标网址。如果WordPress安装在子目录,请包含子目录路径。</p>
</td>
</tr>
<tr>
<th><label for="sps_content_username_{sps_no}">登录用户名</label></th>
<td>
<input type="text" name="sps_content_username[{sps_no}]" id="sps_content_username_{sps_no}" class="sps_input" value="" />
<p>请输入 <span class="sps_username"></span> 网站的登录用户名</p>
</td>
</tr>
<tr>
<th><label for="sps_content_password_{sps_no}">登录密码</label></th>
<td>
<div class="sps_password_box">
<input type="password" name="sps_content_password[{sps_no}]" id="sps_content_password_{sps_no}" class="sps_input" value="" />
<span class="dashicons dashicons-visibility sps_show_pass"></span>
<span class="dashicons dashicons-hidden sps_hide_pass"></span>
</div>
<p>请输入 <span class="sps_password"></span> 网站的登录密码</p>
</td>
</tr>
<tr>
<th><label for="sps_strict_mode_{sps_no}">严格模式</label></th>
<td>
<input type="radio" name="sps_strict_mode[{sps_no}]" value="1" class="sps_radio" id="sps_strict_mode_on_{sps_no}" checked="checked">
<label for="sps_strict_mode_on_{sps_no}">开启 - 源站和目标站的WordPress及插件版本必须一致才能执行同步操作。</label>
<br>
<input type="radio" name="sps_strict_mode[{sps_no}]" value="0" class="sps_radio" id="sps_strict_mode_off_{sps_no}">
<label for="sps_strict_mode_off_{sps_no}">关闭 - 源站和目标站的WordPress及插件版本无需一致。</label>
</td>
</tr>
<tr>
<th><label for="sps_content_match_{sps_no}">内容匹配模式</label></th>
<td>
<select id="sps_content_match_{sps_no}" name="sps_content_match[{sps_no}]" class="sps_select">
<option value="slug">文章别名</option>
</select>
<p>文章别名 - 仅通过文章别名在目标站搜索匹配的内容。</p>
</td>
</tr>
<tr>
<th><label for="sps_roles_allowed_{sps_no}">允许使用的用户角色</label></th>
<td>
<input type="checkbox" class="sps_checkbox" name="sps_roles_allowed[{sps_no}][roles][contributor]" id="sps_roles_contributor_{sps_no}">
<label for="sps_roles_contributor_{sps_no}">投稿者</label><br>
<input type="checkbox" class="sps_checkbox" name="sps_roles_allowed[{sps_no}][roles][author]" id="sps_roles_author_{sps_no}" checked="checked">
<label for="sps_roles_author_{sps_no}">作者</label><br>
<input type="checkbox" class="sps_checkbox" name="sps_roles_allowed[{sps_no}][roles][editor]" id="sps_roles_editor_{sps_no}" checked="checked">
<label for="sps_roles_editor_{sps_no}">编辑</label><br>
<input type="checkbox" class="sps_checkbox" name="sps_roles_allowed[{sps_no}][roles][administrator]" id="sps_roles_administrator_{sps_no}" checked="checked" disabled="disabled">
<label for="sps_roles_administrator_{sps_no}">管理员</label><br>
<p>选择允许使用文章同步功能的用户角色,仅选中的角色可执行同步操作。</p>
</td>
</tr>
<tr>
<th><label for="sps_selected_{sps_no}">默认选中</label></th>
<td>
<input type="checkbox" class="sps_checkbox" name="sps_selected[{sps_no}]" id="sps_selected_{sps_no}" >
<label for="sps_selected_{sps_no}">在添加/编辑文章时自动选中该站点</label><br>
</td>
</tr>
</tbody>
</table>
<hr/>
</div>
</script>
<?php
echo '<p class="add_more_site">';
echo '<input type="button" name="add_more_site" class="button-primary " value="添加更多站点" >';
echo '</p>';
echo '<p class="submit">';
echo '<input type="hidden" name="sps_setting" id="sps_setting" value="sps_setting" />';
echo '<input name="sps_setting_save" class="button-primary sps_setting_save" type="submit" value="保存设置" />';
echo '</p>';
echo '</form>';
echo '</div>';
找到插件里的 plugins/sync-post-with-other-site/includes/sps_settings.view.php
将原先代码全部删除,然后将上面代码复制粘贴进去,保存即可
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END







暂无评论内容