- Cambios
git-svn-id: https://192.168.0.254/svn/Proyectos.FundacionLQDVI_Web/trunk@19 77ab8c26-3d69-2c4d-86f2-786f4ba54905
41
db/lqdvi.sql
@ -1,750 +0,0 @@
|
|||||||
<?php
|
|
||||||
add_action( 'admin_menu', 'akismet_config_page' );
|
|
||||||
add_action( 'admin_menu', 'akismet_stats_page' );
|
|
||||||
akismet_admin_warnings();
|
|
||||||
|
|
||||||
function akismet_admin_init() {
|
|
||||||
global $wp_version;
|
|
||||||
|
|
||||||
// all admin functions are disabled in old versions
|
|
||||||
if ( !function_exists('is_multisite') && version_compare( $wp_version, '3.0', '<' ) ) {
|
|
||||||
|
|
||||||
function akismet_version_warning() {
|
|
||||||
echo "
|
|
||||||
<div id='akismet-warning' class='updated fade'><p><strong>".sprintf(__('Akismet %s requires WordPress 3.0 or higher.'), AKISMET_VERSION) ."</strong> ".sprintf(__('Please <a href="%s">upgrade WordPress</a> to a current version, or <a href="%s">downgrade to version 2.4 of the Akismet plugin</a>.'), 'http://codex.wordpress.org/Upgrading_WordPress', 'http://wordpress.org/extend/plugins/akismet/download/'). "</p></div>
|
|
||||||
";
|
|
||||||
}
|
|
||||||
add_action('admin_notices', 'akismet_version_warning');
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( function_exists( 'get_plugin_page_hook' ) )
|
|
||||||
$hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' );
|
|
||||||
else
|
|
||||||
$hook = 'dashboard_page_akismet-stats-display';
|
|
||||||
add_action('admin_head-'.$hook, 'akismet_stats_script');
|
|
||||||
add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal');
|
|
||||||
wp_register_style('akismet.css', AKISMET_PLUGIN_URL . 'akismet.css');
|
|
||||||
wp_enqueue_style('akismet.css');
|
|
||||||
wp_register_script('akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'));
|
|
||||||
wp_enqueue_script('akismet.js');
|
|
||||||
}
|
|
||||||
add_action('admin_init', 'akismet_admin_init');
|
|
||||||
|
|
||||||
function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
|
|
||||||
$akismet_nonce = 'akismet-update-key';
|
|
||||||
|
|
||||||
function akismet_config_page() {
|
|
||||||
if ( function_exists('add_submenu_page') )
|
|
||||||
add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_plugin_action_links( $links, $file ) {
|
|
||||||
if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) {
|
|
||||||
$links[] = '<a href="plugins.php?page=akismet-key-config">'.__('Settings').'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $links;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_filter( 'plugin_action_links', 'akismet_plugin_action_links', 10, 2 );
|
|
||||||
|
|
||||||
function akismet_conf() {
|
|
||||||
global $akismet_nonce, $wpcom_api_key;
|
|
||||||
|
|
||||||
if ( isset($_POST['submit']) ) {
|
|
||||||
if ( function_exists('current_user_can') && !current_user_can('manage_options') )
|
|
||||||
die(__('Cheatin’ uh?'));
|
|
||||||
|
|
||||||
check_admin_referer( $akismet_nonce );
|
|
||||||
$key = preg_replace( '/[^a-h0-9]/i', '', $_POST['key'] );
|
|
||||||
$home_url = parse_url( get_bloginfo('url') );
|
|
||||||
|
|
||||||
if ( empty($key) ) {
|
|
||||||
$key_status = 'empty';
|
|
||||||
$ms[] = 'new_key_empty';
|
|
||||||
delete_option('wordpress_api_key');
|
|
||||||
} elseif ( empty($home_url['host']) ) {
|
|
||||||
$key_status = 'empty';
|
|
||||||
$ms[] = 'bad_home_url';
|
|
||||||
} else {
|
|
||||||
$key_status = akismet_verify_key( $key );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $key_status == 'valid' ) {
|
|
||||||
update_option('wordpress_api_key', $key);
|
|
||||||
$ms[] = 'new_key_valid';
|
|
||||||
} else if ( $key_status == 'invalid' ) {
|
|
||||||
$ms[] = 'new_key_invalid';
|
|
||||||
} else if ( $key_status == 'failed' ) {
|
|
||||||
$ms[] = 'new_key_failed';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isset( $_POST['akismet_discard_month'] ) )
|
|
||||||
update_option( 'akismet_discard_month', 'true' );
|
|
||||||
else
|
|
||||||
update_option( 'akismet_discard_month', 'false' );
|
|
||||||
|
|
||||||
if ( isset( $_POST['akismet_show_user_comments_approved'] ) )
|
|
||||||
update_option( 'akismet_show_user_comments_approved', 'true' );
|
|
||||||
else
|
|
||||||
update_option( 'akismet_show_user_comments_approved', 'false' );
|
|
||||||
|
|
||||||
} elseif ( isset($_POST['check']) ) {
|
|
||||||
akismet_get_server_connectivity(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( empty( $key_status) || $key_status != 'valid' ) {
|
|
||||||
$key = get_option('wordpress_api_key');
|
|
||||||
if ( empty( $key ) ) {
|
|
||||||
if ( empty( $key_status ) || $key_status != 'failed' ) {
|
|
||||||
if ( akismet_verify_key( '1234567890ab' ) == 'failed' )
|
|
||||||
$ms[] = 'no_connection';
|
|
||||||
else
|
|
||||||
$ms[] = 'key_empty';
|
|
||||||
}
|
|
||||||
$key_status = 'empty';
|
|
||||||
} else {
|
|
||||||
$key_status = akismet_verify_key( $key );
|
|
||||||
}
|
|
||||||
if ( $key_status == 'valid' ) {
|
|
||||||
$ms[] = 'key_valid';
|
|
||||||
} else if ( $key_status == 'invalid' ) {
|
|
||||||
delete_option('wordpress_api_key');
|
|
||||||
$ms[] = 'key_empty';
|
|
||||||
} else if ( !empty($key) && $key_status == 'failed' ) {
|
|
||||||
$ms[] = 'key_failed';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$messages = array(
|
|
||||||
'new_key_empty' => array('color' => 'aa0', 'text' => __('Your key has been cleared.')),
|
|
||||||
'new_key_valid' => array('color' => '4AB915', 'text' => __('Your key has been verified. Happy blogging!')),
|
|
||||||
'new_key_invalid' => array('color' => '888', 'text' => __('The key you entered is invalid. Please double-check it.')),
|
|
||||||
'new_key_failed' => array('color' => '888', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')),
|
|
||||||
'no_connection' => array('color' => '888', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
|
|
||||||
'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (<a href="%s" style="color:#fff">Get your key.</a>)'), 'http://akismet.com/get/')),
|
|
||||||
'key_valid' => array('color' => '4AB915', 'text' => __('This key is valid.')),
|
|
||||||
'key_failed' => array('color' => 'aa0', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.')),
|
|
||||||
'bad_home_url' => array('color' => '888', 'text' => sprintf( __('Your WordPress home URL %s is invalid. Please fix the <a href="%s">home option</a>.'), esc_html( get_bloginfo('url') ), admin_url('options.php#home') ) ),
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
<?php if ( !empty($_POST['submit'] ) ) : ?>
|
|
||||||
<div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<div class="wrap">
|
|
||||||
<h2><?php _e('Akismet Configuration'); ?></h2>
|
|
||||||
<?php if (isset($_GET['message']) && $_GET['message'] == 'success') { ?>
|
|
||||||
<div class="updated below-h2" id="message"><p><?php _e( '<strong>Sign up success!</strong> Please check your email for your Akismet API Key and enter it below.' ); ?></p></div>
|
|
||||||
<?php } ?>
|
|
||||||
<div class="narrow">
|
|
||||||
<form action="" method="post" id="akismet-conf" style="margin: auto; width: 400px; ">
|
|
||||||
<?php if ( !$wpcom_api_key ) { ?>
|
|
||||||
<p><?php printf(__('For many people, <a href="%1$s">Akismet</a> will greatly reduce or even completely eliminate the comment and trackback spam you get on your site. If one does happen to get through, simply mark it as "spam" on the moderation screen and Akismet will learn from the mistakes. If you don\'t have an API key yet, you can get one at <a href="%2$s">Akismet.com</a>.'), 'http://akismet.com/', 'http://akismet.com/get/'); ?></p>
|
|
||||||
|
|
||||||
<h3><label for="key"><?php _e('Akismet API Key'); ?></label></h3>
|
|
||||||
<?php foreach ( $ms as $m ) : ?>
|
|
||||||
<p style="padding: .5em; background-color: #<?php echo $messages[$m]['color']; ?>; color: #fff; font-weight: bold;"><?php echo $messages[$m]['text']; ?></p>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<p><input id="key" name="key" type="text" size="15" maxlength="12" value="<?php echo get_option('wordpress_api_key'); ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php _e('<a href="http://akismet.com/get/">What is this?</a>'); ?>)</p>
|
|
||||||
<?php if ( isset( $invalid_key) && $invalid_key ) { ?>
|
|
||||||
<h3><?php _e('Why might my key be invalid?'); ?></h3>
|
|
||||||
<p><?php _e('This can mean one of two things, either you copied the key wrong or that the plugin is unable to reach the Akismet servers, which is most often caused by an issue with your web host around firewalls or similar.'); ?></p>
|
|
||||||
<?php } ?>
|
|
||||||
<?php } ?>
|
|
||||||
<?php akismet_nonce_field($akismet_nonce) ?>
|
|
||||||
<p><label><input name="akismet_discard_month" id="akismet_discard_month" value="true" type="checkbox" <?php if ( get_option('akismet_discard_month') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Auto-delete spam submitted on posts more than a month old.'); ?></label></p>
|
|
||||||
<p><label><input name="akismet_show_user_comments_approved" id="akismet_show_user_comments_approved" value="true" type="checkbox" <?php if ( get_option('akismet_show_user_comments_approved') == 'true' ) echo ' checked="checked" '; ?> /> <?php _e('Show the number of comments you\'ve approved beside each comment author.'); ?></label></p>
|
|
||||||
<p class="submit"><input type="submit" name="submit" value="<?php _e('Update options »'); ?>" /></p>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form action="" method="post" id="akismet-connectivity" style="margin: auto; width: 400px; ">
|
|
||||||
|
|
||||||
<h3><?php _e('Server Connectivity'); ?></h3>
|
|
||||||
<?php
|
|
||||||
if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') ) {
|
|
||||||
?>
|
|
||||||
<p style="padding: .5em; background-color: #888; color: #fff; font-weight:bold;"><?php _e('Network functions are disabled.'); ?></p>
|
|
||||||
<p><?php echo sprintf( __('Your web host or server administrator has disabled PHP\'s <code>fsockopen</code> or <code>gethostbynamel</code> functions. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet\'s system requirements</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
|
||||||
<?php
|
|
||||||
} else {
|
|
||||||
$servers = akismet_get_server_connectivity();
|
|
||||||
$fail_count = count($servers) - count( array_filter($servers) );
|
|
||||||
if ( is_array($servers) && count($servers) > 0 ) {
|
|
||||||
// some connections work, some fail
|
|
||||||
if ( $fail_count > 0 && $fail_count < count($servers) ) { ?>
|
|
||||||
<p style="padding: .5em; background-color: #aa0; color: #fff; font-weight:bold;"><?php _e('Unable to reach some Akismet servers.'); ?></p>
|
|
||||||
<p><?php echo sprintf( __('A network problem or firewall is blocking some connections from your web server to Akismet.com. Akismet is working but this may cause problems during times of network congestion. Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
|
||||||
<?php
|
|
||||||
// all connections fail
|
|
||||||
} elseif ( $fail_count > 0 ) { ?>
|
|
||||||
<p style="padding: .5em; background-color: #888; color: #fff; font-weight:bold;"><?php _e('Unable to reach any Akismet servers.'); ?></p>
|
|
||||||
<p><?php echo sprintf( __('A network problem or firewall is blocking all connections from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
|
||||||
<?php
|
|
||||||
// all connections work
|
|
||||||
} else { ?>
|
|
||||||
<p style="padding: .5em; background-color: #4AB915; color: #fff; font-weight:bold;"><?php _e('All Akismet servers are available.'); ?></p>
|
|
||||||
<p><?php _e('Akismet is working correctly. All servers are accessible.'); ?></p>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
?>
|
|
||||||
<p style="padding: .5em; background-color: #888; color: #fff; font-weight:bold;"><?php _e('Unable to find Akismet servers.'); ?></p>
|
|
||||||
<p><?php echo sprintf( __('A DNS problem or firewall is preventing all access from your web server to Akismet.com. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet and firewalls</a>.'), 'http://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !empty($servers) ) {
|
|
||||||
?>
|
|
||||||
<table style="width: 100%;">
|
|
||||||
<thead><th><?php _e('Akismet server'); ?></th><th><?php _e('Network Status'); ?></th></thead>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
asort($servers);
|
|
||||||
foreach ( $servers as $ip => $status ) {
|
|
||||||
$color = ( $status ? '#4AB915' : '#888');
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td><?php echo htmlspecialchars($ip); ?></td>
|
|
||||||
<td style="padding: 0 .5em; font-weight:bold; color: #fff; background-color: <?php echo $color; ?>"><?php echo ($status ? __('Accessible') : __('Re-trying') ); ?></td>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<p><?php if ( get_option('akismet_connectivity_time') ) echo sprintf( __('Last checked %s ago.'), human_time_diff( get_option('akismet_connectivity_time') ) ); ?></p>
|
|
||||||
<p class="submit"><input type="submit" name="check" value="<?php _e('Check network status »'); ?>" /></p>
|
|
||||||
<p><?php printf( __('<a href="%s" target="_blank">Click here</a> to confirm that <a href="%s" target="_blank">Akismet.com is up</a>.'), 'http://status.automattic.com/9931/136079/Akismet-API', 'http://status.automattic.com/9931/136079/Akismet-API' ); ?></p>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_stats_page() {
|
|
||||||
if ( function_exists('add_submenu_page') )
|
|
||||||
add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_stats_script() {
|
|
||||||
?>
|
|
||||||
<script type="text/javascript">
|
|
||||||
function resizeIframe() {
|
|
||||||
|
|
||||||
document.getElementById('akismet-stats-frame').style.height = "2500px";
|
|
||||||
|
|
||||||
};
|
|
||||||
function resizeIframeInit() {
|
|
||||||
document.getElementById('akismet-stats-frame').onload = resizeIframe;
|
|
||||||
window.onresize = resizeIframe;
|
|
||||||
}
|
|
||||||
addLoadEvent(resizeIframeInit);
|
|
||||||
</script><?php
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function akismet_stats_display() {
|
|
||||||
global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
|
|
||||||
$blog = urlencode( get_bloginfo('url') );
|
|
||||||
|
|
||||||
$url = 'http://';
|
|
||||||
if ( is_ssl() )
|
|
||||||
$url = 'https://';
|
|
||||||
|
|
||||||
$url .= 'akismet.com/web/1.0/user-stats.php';
|
|
||||||
$url .= "?blog={$blog}&api_key=" . akismet_get_key();
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
<iframe src="<?php echo $url; ?>" width="100%" height="100%" frameborder="0" id="akismet-stats-frame"></iframe>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_stats() {
|
|
||||||
if ( !function_exists('did_action') || did_action( 'rightnow_end' ) ) // We already displayed this info in the "Right Now" section
|
|
||||||
return;
|
|
||||||
if ( !$count = get_option('akismet_spam_count') )
|
|
||||||
return;
|
|
||||||
$path = plugin_basename(__FILE__);
|
|
||||||
echo '<h3>' . _x( 'Spam', 'comments' ) . '</h3>';
|
|
||||||
global $submenu;
|
|
||||||
if ( isset( $submenu['edit-comments.php'] ) )
|
|
||||||
$link = 'edit-comments.php';
|
|
||||||
else
|
|
||||||
$link = 'edit.php';
|
|
||||||
echo '<p>'.sprintf( _n( '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', $count ), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>';
|
|
||||||
}
|
|
||||||
add_action('activity_box_end', 'akismet_stats');
|
|
||||||
|
|
||||||
function akismet_admin_warnings() {
|
|
||||||
global $wpcom_api_key;
|
|
||||||
if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) {
|
|
||||||
function akismet_warning() {
|
|
||||||
echo "
|
|
||||||
<div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet is almost ready.')."</strong> ".sprintf(__('You must <a href="%1$s">enter your Akismet API key</a> for it to work.'), "plugins.php?page=akismet-key-config")."</p></div>
|
|
||||||
";
|
|
||||||
}
|
|
||||||
add_action('admin_notices', 'akismet_warning');
|
|
||||||
return;
|
|
||||||
} elseif ( ( empty($_SERVER['SCRIPT_FILENAME']) || basename($_SERVER['SCRIPT_FILENAME']) == 'edit-comments.php' ) && wp_next_scheduled('akismet_schedule_cron_recheck') ) {
|
|
||||||
function akismet_warning() {
|
|
||||||
global $wpdb;
|
|
||||||
$waiting = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );
|
|
||||||
$next_check = human_time_diff( wp_next_scheduled('akismet_schedule_cron_recheck') );
|
|
||||||
if ( $waiting > 0 )
|
|
||||||
echo "
|
|
||||||
<div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(_n('A server or network problem prevented Akismet from checking %d comment. It has been temporarily held for moderation and will be automatically re-checked in %s.', 'A server or network problem prevented Akismet from checking %d comments. They have been temporarily held for moderation and will be automatically re-checked in %s.', $waiting), number_format_i18n( $waiting ), $next_check)."</p></div>
|
|
||||||
";
|
|
||||||
}
|
|
||||||
add_action('admin_notices', 'akismet_warning');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME placeholder
|
|
||||||
|
|
||||||
function akismet_comment_row_action( $a, $comment ) {
|
|
||||||
|
|
||||||
// failsafe for old WP versions
|
|
||||||
if ( !function_exists('add_comment_meta') )
|
|
||||||
return $a;
|
|
||||||
|
|
||||||
$akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
|
|
||||||
$user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
|
|
||||||
$comment_status = wp_get_comment_status( $comment->comment_ID );
|
|
||||||
$desc = null;
|
|
||||||
if ( !$user_result || $user_result == $akismet_result ) {
|
|
||||||
// Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
|
|
||||||
if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )
|
|
||||||
$desc = __( 'Flagged as spam by Akismet' );
|
|
||||||
elseif ( $akismet_result == 'false' && $comment_status == 'spam' )
|
|
||||||
$desc = __( 'Cleared by Akismet' );
|
|
||||||
} else {
|
|
||||||
$who = get_comment_meta( $comment->comment_ID, 'akismet_user', true );
|
|
||||||
if ( $user_result == 'true' )
|
|
||||||
$desc = sprintf( __('Flagged as spam by %s'), $who );
|
|
||||||
else
|
|
||||||
$desc = sprintf( __('Un-spammed by %s'), $who );
|
|
||||||
}
|
|
||||||
|
|
||||||
// add a History item to the hover links, just after Edit
|
|
||||||
if ( $akismet_result ) {
|
|
||||||
$b = array();
|
|
||||||
foreach ( $a as $k => $item ) {
|
|
||||||
$b[ $k ] = $item;
|
|
||||||
if ( $k == 'edit' )
|
|
||||||
$b['history'] = '<a href="comment.php?action=editcomment&c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' ) . '"> '. __('History') . '</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$a = $b;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $desc )
|
|
||||||
echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' ) . '">'.htmlspecialchars($desc).'</a></span>';
|
|
||||||
|
|
||||||
if ( apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') ) == 'true' ) {
|
|
||||||
$comment_count = akismet_get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
|
|
||||||
$comment_count = intval( $comment_count );
|
|
||||||
echo '<span class="akismet-user-comment-count" commentid="'.$comment->comment_ID.'" style="display:none;"><br><span class="akismet-user-comment-counts">'.sprintf( _n( '%s approved', '%s approved', $comment_count ), number_format_i18n( $comment_count ) ) . '</span></span>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $a;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_filter( 'comment_row_actions', 'akismet_comment_row_action', 10, 2 );
|
|
||||||
|
|
||||||
function akismet_comment_status_meta_box($comment) {
|
|
||||||
$history = akismet_get_comment_history( $comment->comment_ID );
|
|
||||||
|
|
||||||
if ( $history ) {
|
|
||||||
echo '<div class="akismet-history" style="margin: 13px;">';
|
|
||||||
foreach ( $history as $row ) {
|
|
||||||
$time = date( 'D d M Y @ h:i:m a', $row['time'] ) . ' GMT';
|
|
||||||
echo '<div style="margin-bottom: 13px;"><span style="color: #999;" alt="' . $time . '" title="' . $time . '">' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</span> - ';
|
|
||||||
echo htmlspecialchars( $row['message'] ) . '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '</div>';
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// add an extra column header to the comments screen
|
|
||||||
function akismet_comments_columns( $columns ) {
|
|
||||||
$columns[ 'akismet' ] = __( 'Akismet' );
|
|
||||||
return $columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
#add_filter( 'manage_edit-comments_columns', 'akismet_comments_columns' );
|
|
||||||
|
|
||||||
// Show stuff in the extra column
|
|
||||||
function akismet_comment_column_row( $column, $comment_id ) {
|
|
||||||
if ( $column != 'akismet' )
|
|
||||||
return;
|
|
||||||
|
|
||||||
$history = akismet_get_comment_history( $comment_id );
|
|
||||||
|
|
||||||
if ( $history ) {
|
|
||||||
echo '<dl class="akismet-history">';
|
|
||||||
foreach ( $history as $row ) {
|
|
||||||
echo '<dt>' . sprintf( __('%s ago'), human_time_diff( $row['time'] ) ) . '</dt>';
|
|
||||||
echo '<dd>' . htmlspecialchars( $row['message'] ) . '</dd>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '</dl>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#add_action( 'manage_comments_custom_column', 'akismet_comment_column_row', 10, 2 );
|
|
||||||
|
|
||||||
// END FIXME
|
|
||||||
|
|
||||||
// call out URLS in comments
|
|
||||||
function akismet_text_add_link_callback( $m ) {
|
|
||||||
|
|
||||||
// bare link?
|
|
||||||
if ( $m[4] == $m[2] )
|
|
||||||
return '<a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a>';
|
|
||||||
else
|
|
||||||
return '<span title="'.$m[2].'" class="comment-link"><a '.$m[1].' href="'.$m[2].'" '.$m[3].' class="comment-link">'.$m[4].'</a></span>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_text_add_link_class( $comment_text ) {
|
|
||||||
|
|
||||||
return preg_replace_callback( '#<a ([^>]*)href="([^"]+)"([^>]*)>(.*?)</a>#i', 'akismet_text_add_link_callback', $comment_text );
|
|
||||||
}
|
|
||||||
|
|
||||||
add_filter('comment_text', 'akismet_text_add_link_class');
|
|
||||||
|
|
||||||
|
|
||||||
// WP 2.5+
|
|
||||||
function akismet_rightnow() {
|
|
||||||
global $submenu, $wp_db_version;
|
|
||||||
|
|
||||||
// clean_url was deprecated in WP 3.0
|
|
||||||
$esc_url = 'clean_url';
|
|
||||||
if ( function_exists( 'esc_url' ) )
|
|
||||||
$esc_url = 'esc_url';
|
|
||||||
|
|
||||||
if ( 8645 < $wp_db_version ) // 2.7
|
|
||||||
$link = 'edit-comments.php?comment_status=spam';
|
|
||||||
elseif ( isset( $submenu['edit-comments.php'] ) )
|
|
||||||
$link = 'edit-comments.php?page=akismet-admin';
|
|
||||||
else
|
|
||||||
$link = 'edit.php?page=akismet-admin';
|
|
||||||
|
|
||||||
if ( $count = get_option('akismet_spam_count') ) {
|
|
||||||
$intro = sprintf( _n(
|
|
||||||
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
|
|
||||||
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
|
|
||||||
$count
|
|
||||||
), 'http://akismet.com/', number_format_i18n( $count ) );
|
|
||||||
} else {
|
|
||||||
$intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/' );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $queue_count = akismet_spam_count() ) {
|
|
||||||
$queue_text = sprintf( _n(
|
|
||||||
'There\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
|
|
||||||
'There are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
|
|
||||||
$queue_count
|
|
||||||
), number_format_i18n( $queue_count ), $esc_url($link) );
|
|
||||||
} else {
|
|
||||||
$queue_text = sprintf( __( "There's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), $esc_url($link) );
|
|
||||||
}
|
|
||||||
|
|
||||||
$text = $intro . '<br />' . $queue_text;
|
|
||||||
echo "<p class='akismet-right-now'>$text</p>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action('rightnow_end', 'akismet_rightnow');
|
|
||||||
|
|
||||||
|
|
||||||
// For WP >= 2.5
|
|
||||||
function akismet_check_for_spam_button($comment_status) {
|
|
||||||
if ( 'approved' == $comment_status )
|
|
||||||
return;
|
|
||||||
if ( function_exists('plugins_url') )
|
|
||||||
$link = 'admin.php?action=akismet_recheck_queue';
|
|
||||||
else
|
|
||||||
$link = 'edit-comments.php?page=akismet-admin&recheckqueue=true&noheader=true';
|
|
||||||
echo "</div><div class='alignleft'><a class='button-secondary checkforspam' href='$link'>" . __('Check for Spam') . "</a>";
|
|
||||||
}
|
|
||||||
add_action('manage_comments_nav', 'akismet_check_for_spam_button');
|
|
||||||
|
|
||||||
function akismet_submit_nonspam_comment ( $comment_id ) {
|
|
||||||
global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
|
|
||||||
$comment_id = (int) $comment_id;
|
|
||||||
|
|
||||||
$comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
|
|
||||||
if ( !$comment ) // it was deleted
|
|
||||||
return;
|
|
||||||
|
|
||||||
// use the original version stored in comment_meta if available
|
|
||||||
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
|
|
||||||
if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) ) {
|
|
||||||
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
|
||||||
}
|
|
||||||
|
|
||||||
$comment->blog = get_bloginfo('url');
|
|
||||||
$comment->blog_lang = get_locale();
|
|
||||||
$comment->blog_charset = get_option('blog_charset');
|
|
||||||
$comment->permalink = get_permalink($comment->comment_post_ID);
|
|
||||||
$comment->reporter_ip = $_SERVER['REMOTE_ADDR'];
|
|
||||||
if ( is_object($current_user) ) {
|
|
||||||
$comment->reporter = $current_user->user_login;
|
|
||||||
}
|
|
||||||
if ( is_object($current_site) ) {
|
|
||||||
$comment->site_domain = $current_site->domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
$comment->user_role = '';
|
|
||||||
if ( isset( $comment->user_ID ) )
|
|
||||||
$comment->user_role = akismet_get_user_roles($comment->user_ID);
|
|
||||||
|
|
||||||
if ( akismet_test_mode() )
|
|
||||||
$comment->is_test = 'true';
|
|
||||||
|
|
||||||
$query_string = '';
|
|
||||||
foreach ( $comment as $key => $data )
|
|
||||||
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
|
|
||||||
|
|
||||||
$response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-ham", $akismet_api_port);
|
|
||||||
if ( $comment->reporter ) {
|
|
||||||
akismet_update_comment_history( $comment_id, sprintf( __('%s reported this comment as not spam'), $comment->reporter ), 'report-ham' );
|
|
||||||
update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
|
|
||||||
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
|
||||||
}
|
|
||||||
|
|
||||||
do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_submit_spam_comment ( $comment_id ) {
|
|
||||||
global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
|
|
||||||
$comment_id = (int) $comment_id;
|
|
||||||
|
|
||||||
$comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_id'");
|
|
||||||
if ( !$comment ) // it was deleted
|
|
||||||
return;
|
|
||||||
if ( 'spam' != $comment->comment_approved )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// use the original version stored in comment_meta if available
|
|
||||||
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
|
|
||||||
if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) ) {
|
|
||||||
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
|
||||||
}
|
|
||||||
|
|
||||||
$comment->blog = get_bloginfo('url');
|
|
||||||
$comment->blog_lang = get_locale();
|
|
||||||
$comment->blog_charset = get_option('blog_charset');
|
|
||||||
$comment->permalink = get_permalink($comment->comment_post_ID);
|
|
||||||
$comment->reporter_ip = $_SERVER['REMOTE_ADDR'];
|
|
||||||
if ( is_object($current_user) ) {
|
|
||||||
$comment->reporter = $current_user->user_login;
|
|
||||||
}
|
|
||||||
if ( is_object($current_site) ) {
|
|
||||||
$comment->site_domain = $current_site->domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
$comment->user_role = '';
|
|
||||||
if ( isset( $comment->user_ID ) )
|
|
||||||
$comment->user_role = akismet_get_user_roles($comment->user_ID);
|
|
||||||
|
|
||||||
if ( akismet_test_mode() )
|
|
||||||
$comment->is_test = 'true';
|
|
||||||
|
|
||||||
$query_string = '';
|
|
||||||
foreach ( $comment as $key => $data )
|
|
||||||
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
|
|
||||||
|
|
||||||
$response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port);
|
|
||||||
if ( $comment->reporter ) {
|
|
||||||
akismet_update_comment_history( $comment_id, sprintf( __('%s reported this comment as spam'), $comment->reporter ), 'report-spam' );
|
|
||||||
update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
|
|
||||||
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
|
||||||
}
|
|
||||||
do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// For WP 2.7+
|
|
||||||
function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
|
|
||||||
if ( $new_status == $old_status )
|
|
||||||
return;
|
|
||||||
|
|
||||||
# we don't need to record a history item for deleted comments
|
|
||||||
if ( $new_status == 'delete' )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( !is_admin() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
|
|
||||||
return;
|
|
||||||
|
|
||||||
global $current_user;
|
|
||||||
$reporter = '';
|
|
||||||
if ( is_object( $current_user ) )
|
|
||||||
$reporter = $current_user->user_login;
|
|
||||||
|
|
||||||
// Assumption alert:
|
|
||||||
// We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
|
|
||||||
// is changed automatically by another plugin. Unfortunately WordPress doesn't provide an unambiguous way to
|
|
||||||
// determine why the transition_comment_status action was triggered. And there are several different ways by which
|
|
||||||
// to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
|
|
||||||
// We'll assume that this is an explicit user action if POST or GET has an 'action' key.
|
|
||||||
if ( isset($_POST['action']) || isset($_GET['action']) ) {
|
|
||||||
if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
|
|
||||||
return akismet_submit_spam_comment( $comment->comment_ID );
|
|
||||||
} elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
|
|
||||||
return akismet_submit_nonspam_comment( $comment->comment_ID );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
|
|
||||||
akismet_update_comment_history( $comment->comment_ID, sprintf( __('%s changed the comment status to %s'), $reporter, $new_status ), 'status-' . $new_status );
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action( 'transition_comment_status', 'akismet_transition_comment_status', 10, 3 );
|
|
||||||
|
|
||||||
// Total spam in queue
|
|
||||||
// get_option( 'akismet_spam_count' ) is the total caught ever
|
|
||||||
function akismet_spam_count( $type = false ) {
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
if ( !$type ) { // total
|
|
||||||
$count = wp_cache_get( 'akismet_spam_count', 'widget' );
|
|
||||||
if ( false === $count ) {
|
|
||||||
if ( function_exists('wp_count_comments') ) {
|
|
||||||
$count = wp_count_comments();
|
|
||||||
$count = $count->spam;
|
|
||||||
} else {
|
|
||||||
$count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'");
|
|
||||||
}
|
|
||||||
wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );
|
|
||||||
}
|
|
||||||
return $count;
|
|
||||||
} elseif ( 'comments' == $type || 'comment' == $type ) { // comments
|
|
||||||
$type = '';
|
|
||||||
} else { // pingback, trackback, ...
|
|
||||||
$type = $wpdb->escape( $type );
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function akismet_recheck_queue() {
|
|
||||||
global $wpdb, $akismet_api_host, $akismet_api_port;
|
|
||||||
|
|
||||||
if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
$moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A );
|
|
||||||
foreach ( (array) $moderation as $c ) {
|
|
||||||
$c['user_ip'] = $c['comment_author_IP'];
|
|
||||||
$c['user_agent'] = $c['comment_agent'];
|
|
||||||
$c['referrer'] = '';
|
|
||||||
$c['blog'] = get_bloginfo('url');
|
|
||||||
$c['blog_lang'] = get_locale();
|
|
||||||
$c['blog_charset'] = get_option('blog_charset');
|
|
||||||
$c['permalink'] = get_permalink($c['comment_post_ID']);
|
|
||||||
|
|
||||||
$c['user_role'] = '';
|
|
||||||
if ( isset( $c['user_ID'] ) )
|
|
||||||
$c['user_role'] = akismet_get_user_roles($c['user_ID']);
|
|
||||||
|
|
||||||
if ( akismet_test_mode() )
|
|
||||||
$c['is_test'] = 'true';
|
|
||||||
|
|
||||||
$id = (int) $c['comment_ID'];
|
|
||||||
|
|
||||||
$query_string = '';
|
|
||||||
foreach ( $c as $key => $data )
|
|
||||||
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
|
|
||||||
|
|
||||||
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
|
|
||||||
if ( 'true' == $response[1] ) {
|
|
||||||
wp_set_comment_status($c['comment_ID'], 'spam');
|
|
||||||
update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
|
|
||||||
akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam' );
|
|
||||||
|
|
||||||
} elseif ( 'false' == $response[1] ) {
|
|
||||||
update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' );
|
|
||||||
akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham' );
|
|
||||||
// abnormal result: error
|
|
||||||
} else {
|
|
||||||
update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' );
|
|
||||||
akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), $response[1]), 'check-error' );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
wp_redirect( $_SERVER['HTTP_REFERER'] );
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
|
|
||||||
|
|
||||||
// Check connectivity between the WordPress blog and Akismet's servers.
|
|
||||||
// Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect).
|
|
||||||
function akismet_check_server_connectivity() {
|
|
||||||
global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
|
|
||||||
|
|
||||||
$test_host = 'rest.akismet.com';
|
|
||||||
|
|
||||||
// Some web hosts may disable one or both functions
|
|
||||||
if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') )
|
|
||||||
return array();
|
|
||||||
|
|
||||||
$ips = gethostbynamel($test_host);
|
|
||||||
if ( !$ips || !is_array($ips) || !count($ips) )
|
|
||||||
return array();
|
|
||||||
|
|
||||||
$servers = array();
|
|
||||||
foreach ( $ips as $ip ) {
|
|
||||||
$response = akismet_verify_key( akismet_get_key(), $ip );
|
|
||||||
// even if the key is invalid, at least we know we have connectivity
|
|
||||||
if ( $response == 'valid' || $response == 'invalid' )
|
|
||||||
$servers[$ip] = true;
|
|
||||||
else
|
|
||||||
$servers[$ip] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $servers;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the server connectivity and store the results in an option.
|
|
||||||
// Cached results will be used if not older than the specified timeout in seconds; use $cache_timeout = 0 to force an update.
|
|
||||||
// Returns the same associative array as akismet_check_server_connectivity()
|
|
||||||
function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
|
|
||||||
$servers = get_option('akismet_available_servers');
|
|
||||||
if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false )
|
|
||||||
return $servers;
|
|
||||||
|
|
||||||
// There's a race condition here but the effect is harmless.
|
|
||||||
$servers = akismet_check_server_connectivity();
|
|
||||||
update_option('akismet_available_servers', $servers);
|
|
||||||
update_option('akismet_connectivity_time', time());
|
|
||||||
return $servers;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if server connectivity was OK at the last check, false if there was a problem that needs to be fixed.
|
|
||||||
function akismet_server_connectivity_ok() {
|
|
||||||
// skip the check on WPMU because the status page is hidden
|
|
||||||
global $wpcom_api_key;
|
|
||||||
if ( $wpcom_api_key )
|
|
||||||
return true;
|
|
||||||
$servers = akismet_get_server_connectivity();
|
|
||||||
return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
#submitted-on { position: relative; }
|
|
||||||
#the-comment-list .author .akismet-user-comment-count { display: inline; }
|
|
||||||
#dashboard_recent_comments .akismet-status { display: none; } /* never show the flagged by text on the dashboard */
|
|
||||||
.akismet-status { float: right; }
|
|
||||||
.akismet-status a { color: #AAA; font-style: italic; }
|
|
||||||
span.comment-link a { text-decoration: underline; }
|
|
||||||
span.comment-link:after { content: " " attr(title) " "; color: #aaa; text-decoration: none; }
|
|
||||||
|
Before Width: | Height: | Size: 2.7 KiB |
@ -1,10 +0,0 @@
|
|||||||
jQuery(document).ready(function () {
|
|
||||||
jQuery('.akismet-status').each(function () {
|
|
||||||
var thisId = jQuery(this).attr('commentid');
|
|
||||||
jQuery(this).prependTo('#comment-' + thisId + ' .column-comment div:first-child');
|
|
||||||
});
|
|
||||||
jQuery('.akismet-user-comment-count').each(function () {
|
|
||||||
var thisId = jQuery(this).attr('commentid');
|
|
||||||
jQuery(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,512 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @package Akismet
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
Plugin Name: Akismet
|
|
||||||
Plugin URI: http://akismet.com/
|
|
||||||
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your <a href="plugins.php?page=akismet-key-config">Akismet configuration</a> page, and save your API key.
|
|
||||||
Version: 2.5.3
|
|
||||||
Author: Automattic
|
|
||||||
Author URI: http://automattic.com/wordpress-plugins/
|
|
||||||
License: GPLv2 or later
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
define('AKISMET_VERSION', '2.5.3');
|
|
||||||
define('AKISMET_PLUGIN_URL', plugin_dir_url( __FILE__ ));
|
|
||||||
|
|
||||||
/** If you hardcode a WP.com API key here, all key config screens will be hidden */
|
|
||||||
if ( defined('WPCOM_API_KEY') )
|
|
||||||
$wpcom_api_key = constant('WPCOM_API_KEY');
|
|
||||||
else
|
|
||||||
$wpcom_api_key = '';
|
|
||||||
|
|
||||||
// Make sure we don't expose any info if called directly
|
|
||||||
if ( !function_exists( 'add_action' ) ) {
|
|
||||||
echo "Hi there! I'm just a plugin, not much I can do when called directly.";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isset($wp_db_version) && $wp_db_version <= 9872 )
|
|
||||||
include_once dirname( __FILE__ ) . '/legacy.php';
|
|
||||||
|
|
||||||
include_once dirname( __FILE__ ) . '/widget.php';
|
|
||||||
|
|
||||||
if ( is_admin() )
|
|
||||||
require_once dirname( __FILE__ ) . '/admin.php';
|
|
||||||
|
|
||||||
function akismet_init() {
|
|
||||||
global $wpcom_api_key, $akismet_api_host, $akismet_api_port;
|
|
||||||
|
|
||||||
if ( $wpcom_api_key )
|
|
||||||
$akismet_api_host = $wpcom_api_key . '.rest.akismet.com';
|
|
||||||
else
|
|
||||||
$akismet_api_host = get_option('wordpress_api_key') . '.rest.akismet.com';
|
|
||||||
|
|
||||||
$akismet_api_port = 80;
|
|
||||||
}
|
|
||||||
add_action('init', 'akismet_init');
|
|
||||||
|
|
||||||
function akismet_get_key() {
|
|
||||||
global $wpcom_api_key;
|
|
||||||
if ( !empty($wpcom_api_key) )
|
|
||||||
return $wpcom_api_key;
|
|
||||||
return get_option('wordpress_api_key');
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_verify_key( $key, $ip = null ) {
|
|
||||||
global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
|
|
||||||
$blog = urlencode( get_option('home') );
|
|
||||||
if ( $wpcom_api_key )
|
|
||||||
$key = $wpcom_api_key;
|
|
||||||
$response = akismet_http_post("key=$key&blog=$blog", 'rest.akismet.com', '/1.1/verify-key', $akismet_api_port, $ip);
|
|
||||||
if ( !is_array($response) || !isset($response[1]) || $response[1] != 'valid' && $response[1] != 'invalid' )
|
|
||||||
return 'failed';
|
|
||||||
return $response[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we're in debug or test modes, use a reduced service level so as not to polute training or stats data
|
|
||||||
function akismet_test_mode() {
|
|
||||||
if ( defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE )
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a comma-separated list of role names for the given user
|
|
||||||
function akismet_get_user_roles($user_id ) {
|
|
||||||
$roles = false;
|
|
||||||
|
|
||||||
if ( !class_exists('WP_User') )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ( $user_id > 0 ) {
|
|
||||||
$comment_user = new WP_User($user_id);
|
|
||||||
if ( isset($comment_user->roles) )
|
|
||||||
$roles = join(',', $comment_user->roles);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_multisite() && is_super_admin( $user_id ) ) {
|
|
||||||
if ( empty( $roles ) ) {
|
|
||||||
$roles = 'super_admin';
|
|
||||||
} else {
|
|
||||||
$comment_user->roles[] = 'super_admin';
|
|
||||||
$roles = join( ',', $comment_user->roles );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $roles;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns array with headers in $response[0] and body in $response[1]
|
|
||||||
function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
|
|
||||||
global $wp_version;
|
|
||||||
|
|
||||||
$akismet_ua = "WordPress/{$wp_version} | ";
|
|
||||||
$akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' );
|
|
||||||
|
|
||||||
$content_length = strlen( $request );
|
|
||||||
|
|
||||||
$http_host = $host;
|
|
||||||
// use a specific IP if provided
|
|
||||||
// needed by akismet_check_server_connectivity()
|
|
||||||
if ( $ip && long2ip( ip2long( $ip ) ) ) {
|
|
||||||
$http_host = $ip;
|
|
||||||
} else {
|
|
||||||
$http_host = $host;
|
|
||||||
}
|
|
||||||
|
|
||||||
// use the WP HTTP class if it is available
|
|
||||||
if ( function_exists( 'wp_remote_post' ) ) {
|
|
||||||
$http_args = array(
|
|
||||||
'body' => $request,
|
|
||||||
'headers' => array(
|
|
||||||
'Content-Type' => 'application/x-www-form-urlencoded; ' .
|
|
||||||
'charset=' . get_option( 'blog_charset' ),
|
|
||||||
'Host' => $host,
|
|
||||||
'User-Agent' => $akismet_ua
|
|
||||||
),
|
|
||||||
'httpversion' => '1.0',
|
|
||||||
'timeout' => 15
|
|
||||||
);
|
|
||||||
$akismet_url = "http://{$http_host}{$path}";
|
|
||||||
$response = wp_remote_post( $akismet_url, $http_args );
|
|
||||||
if ( is_wp_error( $response ) )
|
|
||||||
return '';
|
|
||||||
|
|
||||||
return array( $response['headers'], $response['body'] );
|
|
||||||
} else {
|
|
||||||
$http_request = "POST $path HTTP/1.0\r\n";
|
|
||||||
$http_request .= "Host: $host\r\n";
|
|
||||||
$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
|
|
||||||
$http_request .= "Content-Length: {$content_length}\r\n";
|
|
||||||
$http_request .= "User-Agent: {$akismet_ua}\r\n";
|
|
||||||
$http_request .= "\r\n";
|
|
||||||
$http_request .= $request;
|
|
||||||
|
|
||||||
$response = '';
|
|
||||||
if( false != ( $fs = @fsockopen( $http_host, $port, $errno, $errstr, 10 ) ) ) {
|
|
||||||
fwrite( $fs, $http_request );
|
|
||||||
|
|
||||||
while ( !feof( $fs ) )
|
|
||||||
$response .= fgets( $fs, 1160 ); // One TCP-IP packet
|
|
||||||
fclose( $fs );
|
|
||||||
$response = explode( "\r\n\r\n", $response, 2 );
|
|
||||||
}
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// filter handler used to return a spam result to pre_comment_approved
|
|
||||||
function akismet_result_spam( $approved ) {
|
|
||||||
// bump the counter here instead of when the filter is added to reduce the possibility of overcounting
|
|
||||||
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
|
|
||||||
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
|
|
||||||
// this is a one-shot deal
|
|
||||||
remove_filter( 'pre_comment_approved', 'akismet_result_spam' );
|
|
||||||
return 'spam';
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_result_hold( $approved ) {
|
|
||||||
// once only
|
|
||||||
remove_filter( 'pre_comment_approved', 'akismet_result_hold' );
|
|
||||||
return '0';
|
|
||||||
}
|
|
||||||
|
|
||||||
// how many approved comments does this author have?
|
|
||||||
function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
if ( !empty($user_id) )
|
|
||||||
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = 1", $user_id ) );
|
|
||||||
|
|
||||||
if ( !empty($comment_author_email) )
|
|
||||||
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_author_email = %s AND comment_author = %s AND comment_author_url = %s AND comment_approved = 1", $comment_author_email, $comment_author, $comment_author_url ) );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_microtime() {
|
|
||||||
$mtime = explode( ' ', microtime() );
|
|
||||||
return $mtime[1] + $mtime[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// log an event for a given comment, storing it in comment_meta
|
|
||||||
function akismet_update_comment_history( $comment_id, $message, $event=null ) {
|
|
||||||
global $current_user;
|
|
||||||
|
|
||||||
// failsafe for old WP versions
|
|
||||||
if ( !function_exists('add_comment_meta') )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
$user = '';
|
|
||||||
if ( is_object($current_user) && isset($current_user->user_login) )
|
|
||||||
$user = $current_user->user_login;
|
|
||||||
|
|
||||||
$event = array(
|
|
||||||
'time' => akismet_microtime(),
|
|
||||||
'message' => $message,
|
|
||||||
'event' => $event,
|
|
||||||
'user' => $user,
|
|
||||||
);
|
|
||||||
|
|
||||||
// $unique = false so as to allow multiple values per comment
|
|
||||||
$r = add_comment_meta( $comment_id, 'akismet_history', $event, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the full comment history for a given comment, as an array in reverse chronological order
|
|
||||||
function akismet_get_comment_history( $comment_id ) {
|
|
||||||
|
|
||||||
// failsafe for old WP versions
|
|
||||||
if ( !function_exists('add_comment_meta') )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
$history = get_comment_meta( $comment_id, 'akismet_history', false );
|
|
||||||
usort( $history, 'akismet_cmp_time' );
|
|
||||||
return $history;
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_cmp_time( $a, $b ) {
|
|
||||||
return $a['time'] > $b['time'] ? -1 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this fires on wp_insert_comment. we can't update comment_meta when akismet_auto_check_comment() runs
|
|
||||||
// because we don't know the comment ID at that point.
|
|
||||||
function akismet_auto_check_update_meta( $id, $comment ) {
|
|
||||||
global $akismet_last_comment;
|
|
||||||
|
|
||||||
// failsafe for old WP versions
|
|
||||||
if ( !function_exists('add_comment_meta') )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// wp_insert_comment() might be called in other contexts, so make sure this is the same comment
|
|
||||||
// as was checked by akismet_auto_check_comment
|
|
||||||
if ( is_object($comment) && !empty($akismet_last_comment) && is_array($akismet_last_comment) ) {
|
|
||||||
if ( intval($akismet_last_comment['comment_post_ID']) == intval($comment->comment_post_ID)
|
|
||||||
&& $akismet_last_comment['comment_author'] == $comment->comment_author
|
|
||||||
&& $akismet_last_comment['comment_author_email'] == $comment->comment_author_email ) {
|
|
||||||
// normal result: true or false
|
|
||||||
if ( $akismet_last_comment['akismet_result'] == 'true' ) {
|
|
||||||
update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' );
|
|
||||||
akismet_update_comment_history( $comment->comment_ID, __('Akismet caught this comment as spam'), 'check-spam' );
|
|
||||||
if ( $comment->comment_approved != 'spam' )
|
|
||||||
akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed'.$comment->comment_approved );
|
|
||||||
} elseif ( $akismet_last_comment['akismet_result'] == 'false' ) {
|
|
||||||
update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
|
|
||||||
akismet_update_comment_history( $comment->comment_ID, __('Akismet cleared this comment'), 'check-ham' );
|
|
||||||
if ( $comment->comment_approved == 'spam' ) {
|
|
||||||
if ( wp_blacklist_check($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent) )
|
|
||||||
akismet_update_comment_history( $comment->comment_ID, __('Comment was caught by wp_blacklist_check'), 'wp-blacklisted' );
|
|
||||||
else
|
|
||||||
akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed-'.$comment->comment_approved );
|
|
||||||
}
|
|
||||||
// abnormal result: error
|
|
||||||
} else {
|
|
||||||
update_comment_meta( $comment->comment_ID, 'akismet_error', time() );
|
|
||||||
akismet_update_comment_history( $comment->comment_ID, sprintf( __('Akismet was unable to check this comment (response: %s), will automatically retry again later.'), $akismet_last_comment['akismet_result']), 'check-error' );
|
|
||||||
}
|
|
||||||
|
|
||||||
// record the complete original data as submitted for checking
|
|
||||||
if ( isset($akismet_last_comment['comment_as_submitted']) )
|
|
||||||
update_comment_meta( $comment->comment_ID, 'akismet_as_submitted', $akismet_last_comment['comment_as_submitted'] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action( 'wp_insert_comment', 'akismet_auto_check_update_meta', 10, 2 );
|
|
||||||
|
|
||||||
|
|
||||||
function akismet_auto_check_comment( $commentdata ) {
|
|
||||||
global $akismet_api_host, $akismet_api_port, $akismet_last_comment;
|
|
||||||
|
|
||||||
$comment = $commentdata;
|
|
||||||
$comment['user_ip'] = $_SERVER['REMOTE_ADDR'];
|
|
||||||
$comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
|
|
||||||
$comment['referrer'] = $_SERVER['HTTP_REFERER'];
|
|
||||||
$comment['blog'] = get_option('home');
|
|
||||||
$comment['blog_lang'] = get_locale();
|
|
||||||
$comment['blog_charset'] = get_option('blog_charset');
|
|
||||||
$comment['permalink'] = get_permalink($comment['comment_post_ID']);
|
|
||||||
|
|
||||||
$comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
|
|
||||||
|
|
||||||
$akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
|
|
||||||
$comment['akismet_comment_nonce'] = 'inactive';
|
|
||||||
if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
|
|
||||||
$comment['akismet_comment_nonce'] = 'failed';
|
|
||||||
if ( isset( $_POST['akismet_comment_nonce'] ) && wp_verify_nonce( $_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'] ) )
|
|
||||||
$comment['akismet_comment_nonce'] = 'passed';
|
|
||||||
|
|
||||||
// comment reply in wp-admin
|
|
||||||
if ( isset( $_POST['_ajax_nonce-replyto-comment'] ) && check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ) )
|
|
||||||
$comment['akismet_comment_nonce'] = 'passed';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( akismet_test_mode() )
|
|
||||||
$comment['is_test'] = 'true';
|
|
||||||
|
|
||||||
foreach ($_POST as $key => $value ) {
|
|
||||||
if ( is_string($value) )
|
|
||||||
$comment["POST_{$key}"] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
|
|
||||||
|
|
||||||
foreach ( $_SERVER as $key => $value ) {
|
|
||||||
if ( !in_array( $key, $ignore ) && is_string($value) )
|
|
||||||
$comment["$key"] = $value;
|
|
||||||
else
|
|
||||||
$comment["$key"] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$query_string = '';
|
|
||||||
foreach ( $comment as $key => $data )
|
|
||||||
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
|
|
||||||
|
|
||||||
$commentdata['comment_as_submitted'] = $comment;
|
|
||||||
|
|
||||||
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
|
|
||||||
$commentdata['akismet_result'] = $response[1];
|
|
||||||
if ( 'true' == $response[1] ) {
|
|
||||||
// akismet_spam_count will be incremented later by akismet_result_spam()
|
|
||||||
add_filter('pre_comment_approved', 'akismet_result_spam');
|
|
||||||
|
|
||||||
do_action( 'akismet_spam_caught' );
|
|
||||||
|
|
||||||
$post = get_post( $comment['comment_post_ID'] );
|
|
||||||
$last_updated = strtotime( $post->post_modified_gmt );
|
|
||||||
$diff = time() - $last_updated;
|
|
||||||
$diff = $diff / 86400;
|
|
||||||
|
|
||||||
if ( $post->post_type == 'post' && $diff > 30 && get_option( 'akismet_discard_month' ) == 'true' && empty($comment['user_ID']) ) {
|
|
||||||
// akismet_result_spam() won't be called so bump the counter here
|
|
||||||
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
|
|
||||||
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
|
|
||||||
wp_redirect( $_SERVER['HTTP_REFERER'] );
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the response is neither true nor false, hold the comment for moderation and schedule a recheck
|
|
||||||
if ( 'true' != $response[1] && 'false' != $response[1] ) {
|
|
||||||
add_filter('pre_comment_approved', 'akismet_result_hold');
|
|
||||||
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
|
|
||||||
// WP 2.1+: delete old comments daily
|
|
||||||
if ( !wp_next_scheduled('akismet_scheduled_delete') )
|
|
||||||
wp_schedule_event(time(), 'daily', 'akismet_scheduled_delete');
|
|
||||||
} elseif ( (mt_rand(1, 10) == 3) ) {
|
|
||||||
// WP 2.0: run this one time in ten
|
|
||||||
akismet_delete_old();
|
|
||||||
}
|
|
||||||
$akismet_last_comment = $commentdata;
|
|
||||||
return $commentdata;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action('preprocess_comment', 'akismet_auto_check_comment', 1);
|
|
||||||
|
|
||||||
function akismet_delete_old() {
|
|
||||||
global $wpdb;
|
|
||||||
$now_gmt = current_time('mysql', 1);
|
|
||||||
$comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");
|
|
||||||
if ( empty( $comment_ids ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
$comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );
|
|
||||||
|
|
||||||
do_action( 'delete_comment', $comment_ids );
|
|
||||||
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( $comma_comment_ids )");
|
|
||||||
$wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id IN ( $comma_comment_ids )");
|
|
||||||
clean_comment_cache( $comment_ids );
|
|
||||||
$n = mt_rand(1, 5000);
|
|
||||||
if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number
|
|
||||||
$wpdb->query("OPTIMIZE TABLE $wpdb->comments");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action('akismet_scheduled_delete', 'akismet_delete_old');
|
|
||||||
|
|
||||||
function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
|
|
||||||
global $wpdb, $akismet_api_host, $akismet_api_port;
|
|
||||||
|
|
||||||
$id = (int) $id;
|
|
||||||
$c = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID = '$id'", ARRAY_A );
|
|
||||||
if ( !$c )
|
|
||||||
return;
|
|
||||||
|
|
||||||
$c['user_ip'] = $c['comment_author_IP'];
|
|
||||||
$c['user_agent'] = $c['comment_agent'];
|
|
||||||
$c['referrer'] = '';
|
|
||||||
$c['blog'] = get_option('home');
|
|
||||||
$c['blog_lang'] = get_locale();
|
|
||||||
$c['blog_charset'] = get_option('blog_charset');
|
|
||||||
$c['permalink'] = get_permalink($c['comment_post_ID']);
|
|
||||||
$id = $c['comment_ID'];
|
|
||||||
if ( akismet_test_mode() )
|
|
||||||
$c['is_test'] = 'true';
|
|
||||||
$c['recheck_reason'] = $recheck_reason;
|
|
||||||
|
|
||||||
$query_string = '';
|
|
||||||
foreach ( $c as $key => $data )
|
|
||||||
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
|
|
||||||
|
|
||||||
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
|
|
||||||
return $response[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_cron_recheck() {
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
delete_option('akismet_available_servers');
|
|
||||||
|
|
||||||
$comment_errors = $wpdb->get_col( "
|
|
||||||
SELECT comment_id
|
|
||||||
FROM {$wpdb->prefix}commentmeta
|
|
||||||
WHERE meta_key = 'akismet_error'
|
|
||||||
LIMIT 100
|
|
||||||
" );
|
|
||||||
|
|
||||||
foreach ( (array) $comment_errors as $comment_id ) {
|
|
||||||
// if the comment no longer exists, remove the meta entry from the queue to avoid getting stuck
|
|
||||||
if ( !get_comment( $comment_id ) ) {
|
|
||||||
delete_comment_meta( $comment_id, 'akismet_error' );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_comment_meta( $comment_id, 'akismet_rechecking', true );
|
|
||||||
$status = akismet_check_db_comment( $comment_id, 'retry' );
|
|
||||||
|
|
||||||
$msg = '';
|
|
||||||
if ( $status == 'true' ) {
|
|
||||||
$msg = __( 'Akismet caught this comment as spam during an automatic retry.' );
|
|
||||||
} elseif ( $status == 'false' ) {
|
|
||||||
$msg = __( 'Akismet cleared this comment during an automatic retry.' );
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we got back a legit response then update the comment history
|
|
||||||
// other wise just bail now and try again later. No point in
|
|
||||||
// re-trying all the comments once we hit one failure.
|
|
||||||
if ( !empty( $msg ) ) {
|
|
||||||
delete_comment_meta( $comment_id, 'akismet_error' );
|
|
||||||
akismet_update_comment_history( $comment_id, $msg, 'cron-retry' );
|
|
||||||
update_comment_meta( $comment_id, 'akismet_result', $status );
|
|
||||||
// make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.
|
|
||||||
$comment = get_comment( $comment_id );
|
|
||||||
if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
|
|
||||||
if ( $status == 'true' ) {
|
|
||||||
wp_spam_comment( $comment_id );
|
|
||||||
} elseif ( $status == 'false' ) {
|
|
||||||
// comment is good, but it's still in the pending queue. depending on the moderation settings
|
|
||||||
// we may need to change it to approved.
|
|
||||||
if ( check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type) )
|
|
||||||
wp_set_comment_status( $comment_id, 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
delete_comment_meta( $comment_id, 'akismet_rechecking' );
|
|
||||||
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$remaining = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );
|
|
||||||
if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
|
|
||||||
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_action( 'akismet_schedule_cron_recheck', 'akismet_cron_recheck' );
|
|
||||||
|
|
||||||
function akismet_add_comment_nonce( $post_id ) {
|
|
||||||
echo '<p style="display: none;">';
|
|
||||||
wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
|
|
||||||
echo '</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
|
|
||||||
|
|
||||||
if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
|
|
||||||
add_action( 'comment_form', 'akismet_add_comment_nonce' );
|
|
||||||
|
|
||||||
if ( '3.0.5' == $wp_version ) {
|
|
||||||
remove_filter( 'comment_text', 'wp_kses_data' );
|
|
||||||
if ( is_admin() )
|
|
||||||
add_filter( 'comment_text', 'wp_kses_post' );
|
|
||||||
}
|
|
||||||
@ -1,396 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
function akismet_spam_comments( $type = false, $page = 1, $per_page = 50 ) {
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
$page = (int) $page;
|
|
||||||
if ( $page < 2 )
|
|
||||||
$page = 1;
|
|
||||||
|
|
||||||
$per_page = (int) $per_page;
|
|
||||||
if ( $per_page < 1 )
|
|
||||||
$per_page = 50;
|
|
||||||
|
|
||||||
$start = ( $page - 1 ) * $per_page;
|
|
||||||
$end = $start + $per_page;
|
|
||||||
|
|
||||||
if ( $type ) {
|
|
||||||
if ( 'comments' == $type || 'comment' == $type )
|
|
||||||
$type = '';
|
|
||||||
else
|
|
||||||
$type = $wpdb->escape( $type );
|
|
||||||
return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type' ORDER BY comment_date DESC LIMIT $start, $end");
|
|
||||||
}
|
|
||||||
|
|
||||||
// All
|
|
||||||
return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT $start, $end");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Totals for each comment type
|
|
||||||
// returns array( type => count, ... )
|
|
||||||
function akismet_spam_totals() {
|
|
||||||
global $wpdb;
|
|
||||||
$totals = $wpdb->get_results( "SELECT comment_type, COUNT(*) AS cc FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_type" );
|
|
||||||
$return = array();
|
|
||||||
foreach ( $totals as $total )
|
|
||||||
$return[$total->comment_type ? $total->comment_type : 'comment'] = $total->cc;
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_manage_page() {
|
|
||||||
global $wpdb, $submenu, $wp_db_version;
|
|
||||||
|
|
||||||
// WP 2.7 has its own spam management page
|
|
||||||
if ( 8645 <= $wp_db_version )
|
|
||||||
return;
|
|
||||||
|
|
||||||
$count = sprintf(__('Akismet Spam (%s)'), akismet_spam_count());
|
|
||||||
if ( isset( $submenu['edit-comments.php'] ) )
|
|
||||||
add_submenu_page('edit-comments.php', __('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught' );
|
|
||||||
elseif ( function_exists('add_management_page') )
|
|
||||||
add_management_page(__('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught');
|
|
||||||
}
|
|
||||||
|
|
||||||
function akismet_caught() {
|
|
||||||
global $wpdb, $comment, $akismet_caught, $akismet_nonce;
|
|
||||||
|
|
||||||
akismet_recheck_queue();
|
|
||||||
if (isset($_POST['submit']) && 'recover' == $_POST['action'] && ! empty($_POST['not_spam'])) {
|
|
||||||
check_admin_referer( $akismet_nonce );
|
|
||||||
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
|
|
||||||
die(__('You do not have sufficient permission to moderate comments.'));
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
foreach ($_POST['not_spam'] as $comment):
|
|
||||||
$comment = (int) $comment;
|
|
||||||
if ( function_exists('wp_set_comment_status') )
|
|
||||||
wp_set_comment_status($comment, 'approve');
|
|
||||||
else
|
|
||||||
$wpdb->query("UPDATE $wpdb->comments SET comment_approved = '1' WHERE comment_ID = '$comment'");
|
|
||||||
akismet_submit_nonspam_comment($comment);
|
|
||||||
++$i;
|
|
||||||
endforeach;
|
|
||||||
$to = add_query_arg( 'recovered', $i, $_SERVER['HTTP_REFERER'] );
|
|
||||||
wp_redirect( $to );
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
if ('delete' == $_POST['action']) {
|
|
||||||
check_admin_referer( $akismet_nonce );
|
|
||||||
if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )
|
|
||||||
die(__('You do not have sufficient permission to moderate comments.'));
|
|
||||||
|
|
||||||
$delete_time = $wpdb->escape( $_POST['display_time'] );
|
|
||||||
$comment_ids = $wpdb->get_col( "SELECT comment_id FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
|
|
||||||
if ( !empty( $comment_ids ) ) {
|
|
||||||
do_action( 'delete_comment', $comment_ids );
|
|
||||||
$wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_id IN ( " . implode( ', ', $comment_ids ) . " )");
|
|
||||||
wp_cache_delete( 'akismet_spam_count', 'widget' );
|
|
||||||
}
|
|
||||||
$to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] );
|
|
||||||
wp_redirect( $to );
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isset( $_GET['recovered'] ) ) {
|
|
||||||
$i = (int) $_GET['recovered'];
|
|
||||||
echo '<div class="updated"><p>' . sprintf(__('%1$s comments recovered.'), $i) . "</p></div>";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset( $_GET['deleted'] ) )
|
|
||||||
echo '<div class="updated"><p>' . __('All spam deleted.') . '</p></div>';
|
|
||||||
|
|
||||||
if ( isset( $GLOBALS['submenu']['edit-comments.php'] ) )
|
|
||||||
$link = 'edit-comments.php';
|
|
||||||
else
|
|
||||||
$link = 'edit.php';
|
|
||||||
?>
|
|
||||||
<style type="text/css">
|
|
||||||
.akismet-tabs {
|
|
||||||
list-style: none;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
clear: both;
|
|
||||||
border-bottom: 1px solid #ccc;
|
|
||||||
height: 31px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
background: #ddd;
|
|
||||||
border-top: 1px solid #bdbdbd;
|
|
||||||
}
|
|
||||||
.akismet-tabs li {
|
|
||||||
float: left;
|
|
||||||
margin: 5px 0 0 20px;
|
|
||||||
}
|
|
||||||
.akismet-tabs a {
|
|
||||||
display: block;
|
|
||||||
padding: 4px .5em 3px;
|
|
||||||
border-bottom: none;
|
|
||||||
color: #036;
|
|
||||||
}
|
|
||||||
.akismet-tabs .active a {
|
|
||||||
background: #fff;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-bottom: none;
|
|
||||||
color: #000;
|
|
||||||
font-weight: bold;
|
|
||||||
padding-bottom: 4px;
|
|
||||||
}
|
|
||||||
#akismetsearch {
|
|
||||||
float: right;
|
|
||||||
margin-top: -.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#akismetsearch p {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<div class="wrap">
|
|
||||||
<h2><?php _e('Caught Spam') ?></h2>
|
|
||||||
<?php
|
|
||||||
$count = get_option( 'akismet_spam_count' );
|
|
||||||
if ( $count ) {
|
|
||||||
?>
|
|
||||||
<p><?php printf(__('Akismet has caught <strong>%1$s spam</strong> for you since you first installed it.'), number_format_i18n($count) ); ?></p>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
$spam_count = akismet_spam_count();
|
|
||||||
|
|
||||||
if ( 0 == $spam_count ) {
|
|
||||||
echo '<p>'.__('You have no spam currently in the queue. Must be your lucky day. :)').'</p>';
|
|
||||||
echo '</div>';
|
|
||||||
} else {
|
|
||||||
echo '<p>'.__('You can delete all of the spam from your database with a single click. This operation cannot be undone, so you may wish to check to ensure that no legitimate comments got through first. Spam is automatically deleted after 15 days, so don’t sweat it.').'</p>';
|
|
||||||
?>
|
|
||||||
<?php if ( !isset( $_POST['s'] ) ) { ?>
|
|
||||||
<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
|
|
||||||
<?php akismet_nonce_field($akismet_nonce) ?>
|
|
||||||
<input type="hidden" name="action" value="delete" />
|
|
||||||
<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?> <input type="submit" class="button delete" name="Submit" value="<?php _e('Delete all'); ?>" />
|
|
||||||
<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" />
|
|
||||||
</form>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
|
||||||
<div class="wrap">
|
|
||||||
<?php if ( isset( $_POST['s'] ) ) { ?>
|
|
||||||
<h2><?php _e('Search'); ?></h2>
|
|
||||||
<?php } else { ?>
|
|
||||||
<?php echo '<p>'.__('These are the latest comments identified as spam by Akismet. If you see any mistakes, simply mark the comment as "not spam" and Akismet will learn from the submission. If you wish to recover a comment from spam, simply select the comment, and click Not Spam. After 15 days we clean out the junk for you.').'</p>'; ?>
|
|
||||||
<?php } ?>
|
|
||||||
<?php
|
|
||||||
if ( isset( $_POST['s'] ) ) {
|
|
||||||
$s = $wpdb->escape($_POST['s']);
|
|
||||||
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE
|
|
||||||
(comment_author LIKE '%$s%' OR
|
|
||||||
comment_author_email LIKE '%$s%' OR
|
|
||||||
comment_author_url LIKE ('%$s%') OR
|
|
||||||
comment_author_IP LIKE ('%$s%') OR
|
|
||||||
comment_content LIKE ('%$s%') ) AND
|
|
||||||
comment_approved = 'spam'
|
|
||||||
ORDER BY comment_date DESC");
|
|
||||||
} else {
|
|
||||||
if ( isset( $_GET['apage'] ) )
|
|
||||||
$page = (int) $_GET['apage'];
|
|
||||||
else
|
|
||||||
$page = 1;
|
|
||||||
|
|
||||||
if ( $page < 2 )
|
|
||||||
$page = 1;
|
|
||||||
|
|
||||||
$current_type = false;
|
|
||||||
if ( isset( $_GET['ctype'] ) )
|
|
||||||
$current_type = preg_replace( '|[^a-z]|', '', $_GET['ctype'] );
|
|
||||||
|
|
||||||
$comments = akismet_spam_comments( $current_type, $page );
|
|
||||||
$total = akismet_spam_count( $current_type );
|
|
||||||
$totals = akismet_spam_totals();
|
|
||||||
?>
|
|
||||||
<ul class="akismet-tabs">
|
|
||||||
<li <?php if ( !isset( $_GET['ctype'] ) ) echo ' class="active"'; ?>><a href="edit-comments.php?page=akismet-admin"><?php _e('All'); ?></a></li>
|
|
||||||
<?php
|
|
||||||
foreach ( $totals as $type => $type_count ) {
|
|
||||||
if ( 'comment' == $type ) {
|
|
||||||
$type = 'comments';
|
|
||||||
$show = __('Comments');
|
|
||||||
} else {
|
|
||||||
$show = ucwords( $type );
|
|
||||||
}
|
|
||||||
$type_count = number_format_i18n( $type_count );
|
|
||||||
$extra = $current_type === $type ? ' class="active"' : '';
|
|
||||||
echo "<li $extra><a href='edit-comments.php?page=akismet-admin&ctype=$type'>$show ($type_count)</a></li>";
|
|
||||||
}
|
|
||||||
do_action( 'akismet_tabs' ); // so plugins can add more tabs easily
|
|
||||||
?>
|
|
||||||
</ul>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($comments) {
|
|
||||||
?>
|
|
||||||
<form method="post" action="<?php echo attribute_escape("$link?page=akismet-admin"); ?>" id="akismetsearch">
|
|
||||||
<p> <input type="text" name="s" value="<?php if (isset($_POST['s'])) echo attribute_escape($_POST['s']); ?>" size="17" />
|
|
||||||
<input type="submit" class="button" name="submit" value="<?php echo attribute_escape(__('Search Spam »')) ?>" /> </p>
|
|
||||||
</form>
|
|
||||||
<?php if ( $total > 50 ) {
|
|
||||||
$total_pages = ceil( $total / 50 );
|
|
||||||
$r = '';
|
|
||||||
if ( 1 < $page ) {
|
|
||||||
$args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
|
|
||||||
$r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('« Previous Page') .'</a>' . "\n";
|
|
||||||
}
|
|
||||||
if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
|
|
||||||
for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
|
|
||||||
if ( $page == $page_num ) :
|
|
||||||
$r .= "<strong>$page_num</strong>\n";
|
|
||||||
else :
|
|
||||||
$p = false;
|
|
||||||
if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
|
|
||||||
$args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
|
|
||||||
$r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
|
|
||||||
$in = true;
|
|
||||||
elseif ( $in == true ) :
|
|
||||||
$r .= "...\n";
|
|
||||||
$in = false;
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
endfor;
|
|
||||||
}
|
|
||||||
if ( ( $page ) * 50 < $total || -1 == $total ) {
|
|
||||||
$args['apage'] = $page + 1;
|
|
||||||
$r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page »') .'</a>' . "\n";
|
|
||||||
}
|
|
||||||
echo "<p>$r</p>";
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php } ?>
|
|
||||||
<form style="clear: both;" method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
|
|
||||||
<?php akismet_nonce_field($akismet_nonce) ?>
|
|
||||||
<input type="hidden" name="action" value="recover" />
|
|
||||||
<ul id="spam-list" class="commentlist" style="list-style: none; margin: 0; padding: 0;">
|
|
||||||
<?php
|
|
||||||
$i = 0;
|
|
||||||
foreach($comments as $comment) {
|
|
||||||
$i++;
|
|
||||||
$comment_date = mysql2date(get_option("date_format") . " @ " . get_option("time_format"), $comment->comment_date);
|
|
||||||
$post = get_post($comment->comment_post_ID);
|
|
||||||
$post_title = $post->post_title;
|
|
||||||
if ($i % 2) $class = 'class="alternate"';
|
|
||||||
else $class = '';
|
|
||||||
echo "\n\t<li id='comment-$comment->comment_ID' $class>";
|
|
||||||
?>
|
|
||||||
|
|
||||||
<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
|
|
||||||
|
|
||||||
<?php comment_text() ?>
|
|
||||||
|
|
||||||
<p><label for="spam-<?php echo $comment->comment_ID; ?>">
|
|
||||||
<input type="checkbox" id="spam-<?php echo $comment->comment_ID; ?>" name="not_spam[]" value="<?php echo $comment->comment_ID; ?>" />
|
|
||||||
<?php _e('Not Spam') ?></label> — <?php comment_date('M j, g:i A'); ?> — [
|
|
||||||
<?php
|
|
||||||
$post = get_post($comment->comment_post_ID);
|
|
||||||
$post_title = wp_specialchars( $post->post_title, 'double' );
|
|
||||||
$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
|
|
||||||
?>
|
|
||||||
<a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] </p>
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</ul>
|
|
||||||
<?php if ( $total > 50 ) {
|
|
||||||
$total_pages = ceil( $total / 50 );
|
|
||||||
$r = '';
|
|
||||||
if ( 1 < $page ) {
|
|
||||||
$args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;
|
|
||||||
$r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('« Previous Page') .'</a>' . "\n";
|
|
||||||
}
|
|
||||||
if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {
|
|
||||||
for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :
|
|
||||||
if ( $page == $page_num ) :
|
|
||||||
$r .= "<strong>$page_num</strong>\n";
|
|
||||||
else :
|
|
||||||
$p = false;
|
|
||||||
if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :
|
|
||||||
$args['apage'] = ( 1 == $page_num ) ? '' : $page_num;
|
|
||||||
$r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";
|
|
||||||
$in = true;
|
|
||||||
elseif ( $in == true ) :
|
|
||||||
$r .= "...\n";
|
|
||||||
$in = false;
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
endfor;
|
|
||||||
}
|
|
||||||
if ( ( $page ) * 50 < $total || -1 == $total ) {
|
|
||||||
$args['apage'] = $page + 1;
|
|
||||||
$r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page »') .'</a>' . "\n";
|
|
||||||
}
|
|
||||||
echo "<p>$r</p>";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<p class="submit">
|
|
||||||
<input type="submit" name="submit" value="<?php echo attribute_escape(__('De-spam marked comments »')); ?>" />
|
|
||||||
</p>
|
|
||||||
<p><?php _e('Comments you de-spam will be submitted to Akismet as mistakes so it can learn and get better.'); ?></p>
|
|
||||||
</form>
|
|
||||||
<?php
|
|
||||||
} else {
|
|
||||||
?>
|
|
||||||
<p><?php _e('No results found.'); ?></p>
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<?php if ( !isset( $_POST['s'] ) ) { ?>
|
|
||||||
<form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>">
|
|
||||||
<?php akismet_nonce_field($akismet_nonce) ?>
|
|
||||||
<p><input type="hidden" name="action" value="delete" />
|
|
||||||
<?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?> <input type="submit" name="Submit" class="button" value="<?php echo attribute_escape(__('Delete all')); ?>" />
|
|
||||||
<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" /></p>
|
|
||||||
</form>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action('admin_menu', 'akismet_manage_page');
|
|
||||||
|
|
||||||
function redirect_old_akismet_urls( ) {
|
|
||||||
global $wp_db_version;
|
|
||||||
$script_name = array_pop( split( '/', $_SERVER['PHP_SELF'] ) );
|
|
||||||
|
|
||||||
$page = '';
|
|
||||||
if ( !empty( $_GET['page'] ) )
|
|
||||||
$page = $_GET['page'];
|
|
||||||
|
|
||||||
// 2.7 redirect for people who might have bookmarked the old page
|
|
||||||
if ( 8204 < $wp_db_version && ( 'edit-comments.php' == $script_name || 'edit.php' == $script_name ) && 'akismet-admin' == $page ) {
|
|
||||||
$new_url = esc_url( 'edit-comments.php?comment_status=spam' );
|
|
||||||
wp_redirect( $new_url, 301 );
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_action( 'admin_init', 'redirect_old_akismet_urls' );
|
|
||||||
|
|
||||||
// For WP <= 2.3.x
|
|
||||||
global $pagenow;
|
|
||||||
|
|
||||||
if ( 'moderation.php' == $pagenow ) {
|
|
||||||
function akismet_recheck_button( $page ) {
|
|
||||||
global $submenu;
|
|
||||||
if ( isset( $submenu['edit-comments.php'] ) )
|
|
||||||
$link = 'edit-comments.php';
|
|
||||||
else
|
|
||||||
$link = 'edit.php';
|
|
||||||
$button = "<a href='$link?page=akismet-admin&recheckqueue=true&noheader=true' style='display: block; width: 100px; position: absolute; right: 7%; padding: 5px; font-size: 14px; text-decoration: underline; background: #fff; border: 1px solid #ccc;'>" . __('Recheck Queue for Spam') . "</a>";
|
|
||||||
$page = str_replace( '<div class="wrap">', '<div class="wrap">' . $button, $page );
|
|
||||||
return $page;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" ) )
|
|
||||||
ob_start( 'akismet_recheck_button' );
|
|
||||||
}
|
|
||||||
|
|
||||||
// This option causes tons of FPs, was removed in 2.1
|
|
||||||
function akismet_kill_proxy_check( $option ) { return 0; }
|
|
||||||
add_filter('option_open_proxy_check', 'akismet_kill_proxy_check');
|
|
||||||
@ -1,130 +0,0 @@
|
|||||||
=== Akismet ===
|
|
||||||
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, automattic
|
|
||||||
Tags: akismet, comments, spam
|
|
||||||
Requires at least: 3.0
|
|
||||||
Tested up to: 3.1
|
|
||||||
Stable tag: 2.5.3
|
|
||||||
License: GPLv2 or later
|
|
||||||
|
|
||||||
Akismet checks your comments against the Akismet web service to see if they look like spam or not.
|
|
||||||
|
|
||||||
== Description ==
|
|
||||||
|
|
||||||
Akismet checks your comments against the Akismet web service to see if they look like spam or not and lets you
|
|
||||||
review the spam it catches under your blog's "Comments" admin screen.
|
|
||||||
|
|
||||||
Major new features in Akismet 2.5 include:
|
|
||||||
|
|
||||||
* A comment status history, so you can easily see which comments were caught or cleared by Akismet, and which were spammed or unspammed by a moderator
|
|
||||||
* Links are highlighted in the comment body, to reveal hidden or misleading links
|
|
||||||
* If your web host is unable to reach Akismet's servers, the plugin will automatically retry when your connection is back up
|
|
||||||
* Moderators can see the number of approved comments for each user
|
|
||||||
* Spam and Unspam reports now include more information, to help improve accuracy
|
|
||||||
|
|
||||||
PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. Keys are free for personal blogs, with paid subscriptions available for businesses and commercial sites.
|
|
||||||
|
|
||||||
== Installation ==
|
|
||||||
|
|
||||||
Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.com API key](http://akismet.com/get/).
|
|
||||||
|
|
||||||
1, 2, 3: You're done!
|
|
||||||
|
|
||||||
== Changelog ==
|
|
||||||
|
|
||||||
= 2.5.3 =
|
|
||||||
* Specify the license is GPL v2 or later
|
|
||||||
* Fix a bug that could result in orphaned commentmeta entries
|
|
||||||
* Include hotfix for WordPress 3.0.5 filter issue
|
|
||||||
|
|
||||||
= 2.5.2 =
|
|
||||||
|
|
||||||
* Properly format the comment count for author counts
|
|
||||||
* Look for super admins on multisite installs when looking up user roles
|
|
||||||
* Increase the HTTP request timeout
|
|
||||||
* Removed padding for author approved count
|
|
||||||
* Fix typo in function name
|
|
||||||
* Set Akismet stats iframe height to fixed 2500px. Better to have one tall scroll bar than two side by side.
|
|
||||||
|
|
||||||
= 2.5.1 =
|
|
||||||
|
|
||||||
* Fix a bug that caused the "Auto delete" option to fail to discard comments correctly
|
|
||||||
* Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce
|
|
||||||
* Fixed padding bug in "author" column of posts screen
|
|
||||||
* Added margin-top to "cleared by ..." badges on dashboard
|
|
||||||
* Fix possible error when calling akismet_cron_recheck()
|
|
||||||
* Fix more PHP warnings
|
|
||||||
* Clean up XHTML warnings for comment nonce
|
|
||||||
* Fix for possible condition where scheduled comment re-checks could get stuck
|
|
||||||
* Clean up the comment meta details after deleting a comment
|
|
||||||
* Only show the status badge if the comment status has been changed by someone/something other than Akismet
|
|
||||||
* Show a 'History' link in the row-actions
|
|
||||||
* Translation fixes
|
|
||||||
* Reduced font-size on author name
|
|
||||||
* Moved "flagged by..." notification to top right corner of comment container and removed heavy styling
|
|
||||||
* Hid "flagged by..." notification while on dashboard
|
|
||||||
|
|
||||||
= 2.5.0 =
|
|
||||||
|
|
||||||
* Track comment actions under 'Akismet Status' on the edit comment screen
|
|
||||||
* Fix a few remaining deprecated function calls ( props Mike Glendinning )
|
|
||||||
* Use HTTPS for the stats IFRAME when wp-admin is using HTTPS
|
|
||||||
* Use the WordPress HTTP class if available
|
|
||||||
* Move the admin UI code to a separate file, only loaded when needed
|
|
||||||
* Add cron retry feature, to replace the old connectivity check
|
|
||||||
* Display Akismet status badge beside each comment
|
|
||||||
* Record history for each comment, and display it on the edit page
|
|
||||||
* Record the complete comment as originally submitted in comment_meta, to use when reporting spam and ham
|
|
||||||
* Highlight links in comment content
|
|
||||||
* New option, "Show the number of comments you've approved beside each comment author."
|
|
||||||
* New option, "Use a nonce on the comment form."
|
|
||||||
|
|
||||||
= 2.4.0 =
|
|
||||||
|
|
||||||
* Spell out that the license is GPLv2
|
|
||||||
* Fix PHP warnings
|
|
||||||
* Fix WordPress deprecated function calls
|
|
||||||
* Fire the delete_comment action when deleting comments
|
|
||||||
* Move code specific for older WP versions to legacy.php
|
|
||||||
* General code clean up
|
|
||||||
|
|
||||||
= 2.3.0 =
|
|
||||||
|
|
||||||
* Fix "Are you sure" nonce message on config screen in WPMU
|
|
||||||
* Fix XHTML compliance issue in sidebar widget
|
|
||||||
* Change author link; remove some old references to WordPress.com accounts
|
|
||||||
* Localize the widget title (core ticket #13879)
|
|
||||||
|
|
||||||
= 2.2.9 =
|
|
||||||
|
|
||||||
* Eliminate a potential conflict with some plugins that may cause spurious reports
|
|
||||||
|
|
||||||
= 2.2.8 =
|
|
||||||
|
|
||||||
* Fix bug in initial comment check for ipv6 addresses
|
|
||||||
* Report comments as ham when they are moved from spam to moderation
|
|
||||||
* Report comments as ham when clicking undo after spam
|
|
||||||
* Use transition_comment_status action when available instead of older actions for spam/ham submissions
|
|
||||||
* Better diagnostic messages when PHP network functions are unavailable
|
|
||||||
* Better handling of comments by logged-in users
|
|
||||||
|
|
||||||
= 2.2.7 =
|
|
||||||
|
|
||||||
* Add a new AKISMET_VERSION constant
|
|
||||||
* Reduce the possibility of over-counting spam when another spam filter plugin is in use
|
|
||||||
* Disable the connectivity check when the API key is hard-coded for WPMU
|
|
||||||
|
|
||||||
= 2.2.6 =
|
|
||||||
|
|
||||||
* Fix a global warning introduced in 2.2.5
|
|
||||||
* Add changelog and additional readme.txt tags
|
|
||||||
* Fix an array conversion warning in some versions of PHP
|
|
||||||
* Support a new WPCOM_API_KEY constant for easier use with WordPress MU
|
|
||||||
|
|
||||||
= 2.2.5 =
|
|
||||||
|
|
||||||
* Include a new Server Connectivity diagnostic check, to detect problems caused by firewalls
|
|
||||||
|
|
||||||
= 2.2.4 =
|
|
||||||
|
|
||||||
* Fixed a key problem affecting the stats feature in WordPress MU
|
|
||||||
* Provide additional blog information in Akismet API calls
|
|
||||||
@ -1,90 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @package Akismet
|
|
||||||
*/
|
|
||||||
// Widget stuff
|
|
||||||
function widget_akismet_register() {
|
|
||||||
if ( function_exists('register_sidebar_widget') ) :
|
|
||||||
function widget_akismet($args) {
|
|
||||||
extract($args);
|
|
||||||
$options = get_option('widget_akismet');
|
|
||||||
$count = get_option('akismet_spam_count');
|
|
||||||
?>
|
|
||||||
<?php echo $before_widget; ?>
|
|
||||||
<?php echo $before_title . $options['title'] . $after_title; ?>
|
|
||||||
<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><?php printf( _n( '%1$s%2$s%3$s %4$sspam comment%5$s %6$sblocked by%7$s<br />%8$sAkismet%9$s', '%1$s%2$s%3$s %4$sspam comments%5$s %6$sblocked by%7$s<br />%8$sAkismet%9$s', $count ), '<span id="akismet1"><span id="akismetcount">', number_format_i18n( $count ), '</span>', '<span id="akismetsc">', '</span></span>', '<span id="akismet2"><span id="akismetbb">', '</span>', '<span id="akismeta">', '</span></span>' ); ?></a></div></div>
|
|
||||||
<?php echo $after_widget; ?>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function widget_akismet_style() {
|
|
||||||
$plugin_dir = '/wp-content/plugins';
|
|
||||||
if ( defined( 'PLUGINDIR' ) )
|
|
||||||
$plugin_dir = '/' . PLUGINDIR;
|
|
||||||
|
|
||||||
?>
|
|
||||||
<style type="text/css">
|
|
||||||
#aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
|
|
||||||
#aka:hover{border:none;text-decoration:none}
|
|
||||||
#aka:hover #akismet1{display:none}
|
|
||||||
#aka:hover #akismet2,#akismet1{display:block}
|
|
||||||
#akismet2{display:none;padding-top:2px}
|
|
||||||
#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
|
|
||||||
#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
|
|
||||||
#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'), $plugin_dir; ?>/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
|
|
||||||
</style>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function widget_akismet_control() {
|
|
||||||
$options = $newoptions = get_option('widget_akismet');
|
|
||||||
if ( isset( $_POST['akismet-submit'] ) && $_POST["akismet-submit"] ) {
|
|
||||||
$newoptions['title'] = strip_tags(stripslashes($_POST["akismet-title"]));
|
|
||||||
if ( empty($newoptions['title']) ) $newoptions['title'] = __('Spam Blocked');
|
|
||||||
}
|
|
||||||
if ( $options != $newoptions ) {
|
|
||||||
$options = $newoptions;
|
|
||||||
update_option('widget_akismet', $options);
|
|
||||||
}
|
|
||||||
$title = htmlspecialchars($options['title'], ENT_QUOTES);
|
|
||||||
?>
|
|
||||||
<p><label for="akismet-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="akismet-title" name="akismet-title" type="text" value="<?php echo $title; ?>" /></label></p>
|
|
||||||
<input type="hidden" id="akismet-submit" name="akismet-submit" value="1" />
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( function_exists( 'wp_register_sidebar_widget' ) ) {
|
|
||||||
wp_register_sidebar_widget( 'akismet', 'Akismet', 'widget_akismet', null, 'akismet');
|
|
||||||
wp_register_widget_control( 'akismet', 'Akismet', 'widget_akismet_control', null, 75, 'akismet');
|
|
||||||
} else {
|
|
||||||
register_sidebar_widget('Akismet', 'widget_akismet', null, 'akismet');
|
|
||||||
register_widget_control('Akismet', 'widget_akismet_control', null, 75, 'akismet');
|
|
||||||
}
|
|
||||||
if ( is_active_widget('widget_akismet') )
|
|
||||||
add_action('wp_head', 'widget_akismet_style');
|
|
||||||
endif;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action('init', 'widget_akismet_register');
|
|
||||||
|
|
||||||
// Counter for non-widget users
|
|
||||||
function akismet_counter() {
|
|
||||||
$plugin_dir = '/wp-content/plugins';
|
|
||||||
if ( defined( 'PLUGINDIR' ) )
|
|
||||||
$plugin_dir = '/' . PLUGINDIR;
|
|
||||||
|
|
||||||
?>
|
|
||||||
<style type="text/css">
|
|
||||||
#akismetwrap #aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
|
|
||||||
#aka:hover{border:none;text-decoration:none}
|
|
||||||
#aka:hover #akismet1{display:none}
|
|
||||||
#aka:hover #akismet2,#akismet1{display:block}
|
|
||||||
#akismet2{display:none;padding-top:2px}
|
|
||||||
#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
|
|
||||||
#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
|
|
||||||
#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'), $plugin_dir; ?>/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
|
|
||||||
</style>
|
|
||||||
<?php
|
|
||||||
$count = get_option('akismet_spam_count');
|
|
||||||
printf( _n( '<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount">%1$s</span> <span id="akismetsc">spam comment</span></div> <div id="akismet2"><span id="akismetbb">blocked by</span><br /><span id="akismeta">Akismet</span></div></a></div></div>', '<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount">%1$s</span> <span id="akismetsc">spam comments</span></div> <div id="akismet2"><span id="akismetbb">blocked by</span><br /><span id="akismeta">Akismet</span></div></a></div></div>', $count ), number_format_i18n( $count ) );
|
|
||||||
}
|
|
||||||
@ -1,473 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
Plugin Name: FaceThumb
|
|
||||||
Plugin URI: http://www.mnt-tech.fr/blog/
|
|
||||||
Description: The plugin allows your visitors to post thumbnails on your blog.
|
|
||||||
Version: 0.0.4
|
|
||||||
Author: MNT-Tech S.A.R.L.
|
|
||||||
Author URI: http://www.mnt-tech.fr/
|
|
||||||
*/
|
|
||||||
|
|
||||||
$plugin_dir = basename(dirname(__FILE__));
|
|
||||||
load_plugin_textdomain( 'facethumb', 'wp-content/plugins/' . $plugin_dir, $plugin_dir . '/languages' );
|
|
||||||
|
|
||||||
function calculate_gallery($admin) {
|
|
||||||
global $wpdb;
|
|
||||||
$post = $wpdb->prefix . "posts";
|
|
||||||
$plugin = $wpdb->prefix . "facethumb";
|
|
||||||
$column = get_option( 'facethumb_column' );
|
|
||||||
$line = get_option( 'facethumb_line' );
|
|
||||||
$photo_per_page = $line * $column;
|
|
||||||
$number_of_photo = $wpdb->get_var( "SELECT COUNT(*) FROM $plugin" );
|
|
||||||
$number_of_page = ceil( $number_of_photo / $photo_per_page ); //ceil : entier supérieur
|
|
||||||
if ( isset( $_GET['ppmnt']) AND $_GET['ppmnt'] != NULL AND $_GET['ppmnt'] > 0 AND $_GET['ppmnt'] <= $number_of_page ) {
|
|
||||||
$number_of_current_page = $_GET['ppmnt'];
|
|
||||||
$start = ( $photo_per_page * ( $number_of_current_page - 1 ) ) + 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$number_of_current_page = 1;
|
|
||||||
$start = 1;
|
|
||||||
}
|
|
||||||
$stop = $number_of_current_page * $photo_per_page;
|
|
||||||
$photo_to_display = $number_of_photo - ($start - 1);
|
|
||||||
$display = '';
|
|
||||||
if ( $number_of_photo == 0 ) {
|
|
||||||
$display .= '<p>'. __('Sorry, no photos have been taken yet!', 'facethumb') .'</p><br/>';
|
|
||||||
}
|
|
||||||
elseif ( $photo_to_display < $photo_per_page ) {
|
|
||||||
$stop_display = 1; // Permet de ne pas afficher des cases vides dans le tableau, s'il n'y a pas assez de photo pour remplir la page
|
|
||||||
if ( $admin == 1 AND $number_of_photo != 0) {
|
|
||||||
$cible = str_replace( '%7E', '~', $_SERVER['REQUEST_URI']);
|
|
||||||
$display .= '<form name="form1" method="post" action="'.$cible.'">';
|
|
||||||
$display .= '<input type="hidden" name="delete_hidden" value="Y">';
|
|
||||||
$display .= '<input type="hidden" name="start_hidden" value="'.$start.'">';
|
|
||||||
}
|
|
||||||
$display .= '<table>';
|
|
||||||
for ( $line_count = 1; $line_count <= $line AND $photo_to_display >= $stop_display; $line_count++ ) {
|
|
||||||
$display .= '<tr>';
|
|
||||||
for ($compteur_colonne = 1; $compteur_colonne <= $column AND $photo_to_display >= $stop_display; $compteur_colonne++) {
|
|
||||||
$display .= '<td>';
|
|
||||||
$id_photo = $number_of_photo - $start;
|
|
||||||
$current_photo = $wpdb->get_row( "SELECT * FROM $plugin ORDER BY id LIMIT $id_photo, 1" );
|
|
||||||
while ( $current_photo->url == NULL AND $start <= $stop ) { // Elimine les id des éléments supprimés de la BDD.
|
|
||||||
$start ++;
|
|
||||||
$current_photo = $wpdb->get_row( "SELECT * FROM $plugin ORDER BY id LIMIT $id_photo, 1" );
|
|
||||||
}
|
|
||||||
if ( (get_option('facethumb_link') == 'gallery' OR get_option('facethumb_link') == 'both') AND $current_photo->link != "none") {
|
|
||||||
$display .= '<a href="' . htmlspecialchars($current_photo->link) . '">';
|
|
||||||
}
|
|
||||||
$display .= '<img src="' . htmlspecialchars($current_photo->url) . '" alt="' . htmlspecialchars($current_photo->name) . '" />';
|
|
||||||
if ( (get_option('facethumb_link') == 'gallery' OR get_option('facethumb_link') == 'both') AND $current_photo->link != "none") {
|
|
||||||
$display .= '</a>';
|
|
||||||
}
|
|
||||||
$timestamp = $current_photo->time;
|
|
||||||
$display .= '<br/> '. __('the ', 'facethumb') . date( 'Y-m-d', $timestamp ). __(' at ','facethumb') .date( 'H:i', $timestamp ) . '<br/>'. __('by ', 'facethumb') . htmlspecialchars($current_photo->name);
|
|
||||||
if ( $admin == 1) {
|
|
||||||
$display .= '<br/><input type="checkbox" name="delete_'.$current_photo->id.'" />';
|
|
||||||
}
|
|
||||||
$display .= '</td>';
|
|
||||||
$start ++;
|
|
||||||
$stop_display ++;
|
|
||||||
}
|
|
||||||
$display .= '</tr>';
|
|
||||||
}
|
|
||||||
$display .= '</table><br/>';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ( $admin == 1 AND $number_of_photo != 0) {
|
|
||||||
$cible = str_replace( '%7E', '~', $_SERVER['REQUEST_URI']);
|
|
||||||
$display .= '<form name="form1" method="post" action="'.$cible.'">';
|
|
||||||
$display .= '<input type="hidden" name="delete_hidden" value="Y">';
|
|
||||||
$display .= '<input type="hidden" name="start_hidden" value="'.$start.'">';
|
|
||||||
}
|
|
||||||
$display .= '<table>';
|
|
||||||
for ( $line_count = 1; $line_count <= $line; $line_count++ ) {
|
|
||||||
$display .= '<tr>';
|
|
||||||
for ($compteur_colonne = 1; $compteur_colonne <= $column; $compteur_colonne++) {
|
|
||||||
$display .= '<td>';
|
|
||||||
$id_photo = $number_of_photo - $start;
|
|
||||||
$current_photo = $wpdb->get_row( "SELECT * FROM $plugin ORDER BY id LIMIT $id_photo, 1" );
|
|
||||||
while ( $current_photo->url == NULL AND $start <= $stop ) { // Elimine les id des éléments supprimés de la BDD.
|
|
||||||
$start ++;
|
|
||||||
$current_photo = $wpdb->get_row( "SELECT * FROM $plugin ORDER BY id LIMIT $id_photo, 1" );
|
|
||||||
}
|
|
||||||
if ( (get_option('facethumb_link') == 'gallery' OR get_option('facethumb_link') == 'both') AND $current_photo->link != "none") {
|
|
||||||
$display .= '<a href="' . htmlspecialchars($current_photo->link) . '">';
|
|
||||||
}
|
|
||||||
$display .= '<img src="' . htmlspecialchars($current_photo->url) . '" alt="' . htmlspecialchars($current_photo->name) . '" />';
|
|
||||||
if ( (get_option('facethumb_link') == 'gallery' OR get_option('facethumb_link') == 'both') AND $current_photo->link != "none") {
|
|
||||||
$display .= '</a>';
|
|
||||||
}
|
|
||||||
$timestamp = $current_photo->time;
|
|
||||||
$display .= '<br/> '. __('the ', 'facethumb') . date( 'Y-m-d', $timestamp ). __(' at ','facethumb') .date( 'H:i', $timestamp ) . '<br/>'. __('by ', 'facethumb') . htmlspecialchars($current_photo->name);
|
|
||||||
if ( $admin == 1) {
|
|
||||||
$display .= '<br/><input type="checkbox" name="delete_'.$current_photo->id.'" />';
|
|
||||||
}
|
|
||||||
$display .= '</td>';
|
|
||||||
$start ++;
|
|
||||||
}
|
|
||||||
$display .= '</tr>';
|
|
||||||
}
|
|
||||||
$display .= '</table><br/>';
|
|
||||||
}
|
|
||||||
// Affichage de la pagination
|
|
||||||
$id_page = $wpdb->get_var( "SELECT ID FROM $post WHERE post_content='[FaceThumb WordPress MNTT]' AND post_title='FaceThumb Gallery'" );
|
|
||||||
$start_float = $number_of_current_page - 2;
|
|
||||||
$stop_float = $number_of_current_page + 2;
|
|
||||||
if ( $start_float <= 0 ) {
|
|
||||||
$start_float = 1;
|
|
||||||
}
|
|
||||||
if ( $stop_float > $number_of_page ) {
|
|
||||||
$stop_float = $number_of_page;
|
|
||||||
}
|
|
||||||
if ( $admin == 1) {
|
|
||||||
$url = get_bloginfo( 'url' ) . '/wp-admin/admin.php?page=manage-gallery';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$url = get_bloginfo( 'url' ). '/?page_id=' . $id_page;
|
|
||||||
}
|
|
||||||
if ( $start_float == 1 AND $stop_float == 1 ) {
|
|
||||||
$display .= __('Pages', 'facethumb'). ' : 1';
|
|
||||||
}
|
|
||||||
elseif ( $start_float > 1 AND $stop_float < $number_of_page ) {
|
|
||||||
$display .= __('Pages', 'facethumb').' : ';
|
|
||||||
$display .= '<a href="' . $url . '&ppmnt=1">1</a> ... ';
|
|
||||||
for ( $i = $start_float; $i <= $number_of_current_page - 1; $i ++) {
|
|
||||||
$display .= '<a href="' . $url . '&ppmnt=' . $i . '">' . $i . '</a> ';
|
|
||||||
}
|
|
||||||
$display .= $i . ' ';
|
|
||||||
for ( $i = $number_of_current_page + 1; $i <= $stop_float; $i ++) {
|
|
||||||
$display .= '<a href="' . $url . '&ppmnt=' . $i . '">' . $i . '</a> ';
|
|
||||||
}
|
|
||||||
$display .= '... <a href="' . $url . '&ppmnt=' . $number_of_page . '">' . $number_of_page . '</a>';
|
|
||||||
}
|
|
||||||
elseif ( $start_float == 1 AND $stop_float == $number_of_page ) {
|
|
||||||
$display .= __('Pages', 'facethumb').' : ';
|
|
||||||
for ( $i = $start_float; $i <= $number_of_current_page - 1; $i ++) {
|
|
||||||
$display .= '<a href="' . $url . '&ppmnt=' . $i . '">' . $i . '</a> ';
|
|
||||||
}
|
|
||||||
$display .= $i . ' ';
|
|
||||||
for ( $i = $number_of_current_page + 1; $i <= $stop_float; $i ++) {
|
|
||||||
$display .= '<a href="' . $url . '&ppmnt=' . $i . '">' . $i . '</a> ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ( $start_float == 1 AND $stop_float != $number_of_page ) {
|
|
||||||
$display .= __('Pages', 'facethumb').' : ';
|
|
||||||
for ( $i = $start_float; $i <= $number_of_current_page - 1; $i ++) {
|
|
||||||
$display .= '<a href="' . $url . '&ppmnt=' . $i . '">' . $i . '</a> ';
|
|
||||||
}
|
|
||||||
$display .= $i . ' ';
|
|
||||||
for ( $i = $number_of_current_page + 1; $i <= $stop_float; $i ++) {
|
|
||||||
$display .= '<a href="' . $url . '&ppmnt=' . $i . '">' . $i . '</a> ';
|
|
||||||
}
|
|
||||||
$display .= '... <a href="' . $url . '&ppmnt=' . $number_of_page . '">' . $number_of_page . '</a>';
|
|
||||||
}
|
|
||||||
elseif ( $start_float != 1 AND $stop_float == $number_of_page ) {
|
|
||||||
$display .= __('Pages', 'facethumb').' : ';
|
|
||||||
$display .= '<a href="' . $url . '&ppmnt=1">1</a> ... ';
|
|
||||||
for ( $i = $start_float; $i <= $number_of_current_page - 1; $i ++) {
|
|
||||||
$display .= '<a href="' . $url . '&ppmnt=' . $i . '">' . $i . '</a> ';
|
|
||||||
}
|
|
||||||
$display .= $i . ' ';
|
|
||||||
for ( $i = $number_of_current_page + 1; $i <= $stop_float; $i ++) {
|
|
||||||
$display .= '<a href="' . $url . '&ppmnt=' . $i . '">' . $i . '</a> ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Fin de pagination
|
|
||||||
|
|
||||||
if ( $admin == 1 AND $number_of_photo != 0) {
|
|
||||||
$display .= '<p class="submit">';
|
|
||||||
$display .= '<input type="submit" name="Submit" value="' . __('Delete Thumbnails', 'facethumb') . '" />';
|
|
||||||
$display .= '</p>';
|
|
||||||
$display .= '</form>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $display;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
add_action("widgets_init", array('FaceThumb', 'register'));
|
|
||||||
register_activation_hook( __FILE__, array('FaceThumb', 'plugin_install'));
|
|
||||||
|
|
||||||
class FaceThumb {
|
|
||||||
function plugin_install(){
|
|
||||||
global $wpdb;
|
|
||||||
global $plugin_db_version;
|
|
||||||
|
|
||||||
$table_name = $wpdb->prefix . "facethumb";
|
|
||||||
if( $wpdb->get_var("show tables like '$table_name'") != $table_name ) {
|
|
||||||
$sql1 = "CREATE TABLE " . $table_name . " (
|
|
||||||
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
|
||||||
time bigint(11) DEFAULT '0' NOT NULL,
|
|
||||||
name tinytext NOT NULL,
|
|
||||||
url VARCHAR(100) NOT NULL,
|
|
||||||
link VARCHAR(100) NOT NULL,
|
|
||||||
UNIQUE KEY id (id)
|
|
||||||
);";
|
|
||||||
|
|
||||||
$wpdb->query($sql1);
|
|
||||||
add_option("plugin_db_version", $plugin_db_version);
|
|
||||||
}
|
|
||||||
|
|
||||||
$post = $wpdb->prefix . "posts";
|
|
||||||
$date = date( 'Y-m-d H:i:s' );
|
|
||||||
$first_install = $wpdb->get_var( "SELECT ID FROM $post WHERE post_content='[FaceThumb WordPress MNTT]' AND post_title='FaceThumb Gallery'" );
|
|
||||||
if ( !($first_install > 0) ) {
|
|
||||||
$id = $wpdb->get_var( "SELECT ID FROM $post ORDER BY ID DESC LIMIT 0, 1" );
|
|
||||||
$id ++;
|
|
||||||
$adress = get_bloginfo('url') . '/?page_id=' . $id;
|
|
||||||
$wpdb->query( "INSERT INTO $post VALUES ('$id', '1', '$date', '$date', '[FaceThumb WordPress MNTT]', 'FaceThumb Gallery', '','publish', 'closed', 'closed', '', 'facethumb-gallery', '', '', '$date', '$date' , '', '0', '$adress', '0', 'page', '', '0' )");
|
|
||||||
$time = time();
|
|
||||||
$base = get_bloginfo('url') . '/wp-content/plugins/facethumb/uploads/mnt-tech.jpg';
|
|
||||||
$wpdb->query( "INSERT INTO $table_name VALUES ('', '$time', 'MNT-Tech', '$base', 'http://www.mnt-tech.fr/blog/')" );
|
|
||||||
}
|
|
||||||
$options = $wpdb->prefix . "options";
|
|
||||||
$is_set = $wpdb->get_var( "SELECT ID FROM $options WHERE option_name='facethumb_column'" );
|
|
||||||
if ( !($is_set > 0) ) {
|
|
||||||
$wpdb->query( "INSERT INTO $options VALUES ('', '0', 'facethumb_column', '3', 'yes')" );
|
|
||||||
$wpdb->query( "INSERT INTO $options VALUES ('', '0', 'facethumb_line', '5', 'yes')" );
|
|
||||||
$wpdb->query( "INSERT INTO $options VALUES ('', '0', 'facethumb_widget', 'last', 'yes')" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function display_plugin($args) {
|
|
||||||
global $wpdb;
|
|
||||||
$table_name = $wpdb->prefix . "facethumb";
|
|
||||||
$post = $wpdb->prefix . "posts";
|
|
||||||
$url = get_bloginfo('url') . '/wp-content/plugins/facethumb/flash.php';
|
|
||||||
$thumb_url = $wpdb->get_var( "SELECT guid FROM $post WHERE post_content='[FaceThumb WordPress MNTT]' AND post_title='FaceThumb Gallery'" );
|
|
||||||
$facethumb_widget = get_option('facethumb_widget');
|
|
||||||
if ( $facethumb_widget == 'random' ) {
|
|
||||||
$number_of_photo = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
|
|
||||||
$photo_number = rand(0, $number_of_photo-1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$number_of_photo = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
|
|
||||||
$photo_number = $number_of_photo - 1;
|
|
||||||
}
|
|
||||||
$pic_info = $wpdb->get_row( "SELECT * FROM $table_name ORDER BY id LIMIT $photo_number, 1 " );
|
|
||||||
echo $args['before_widget'];
|
|
||||||
echo $args['before_title'] . '<a href="http://www.mnt-tech.fr/blog/tag/facethumb/" title="FaceThumb 0.0.4">FaceThumb</a>' . $args['after_title'];
|
|
||||||
if ( $pic_info->url != NULL ) {
|
|
||||||
if ( (get_option('facethumb_link') == 'widget' OR get_option('facethumb_link') == 'both') AND $pic_info->link != "none") {
|
|
||||||
echo '<a href="' . htmlspecialchars($pic_info->link) . '" style="margin: auto;">';
|
|
||||||
}
|
|
||||||
echo '<img src="' . $pic_info->url . '" alt="' . htmlspecialchars($pic_info->name) . '" style="margin-left: 10px; margin-top: 10px;" />';
|
|
||||||
if ( (get_option('facethumb_link') == 'widget' OR get_option('facethumb_link') == 'both') AND $pic_info->link != "none") {
|
|
||||||
echo '</a>';
|
|
||||||
}
|
|
||||||
echo '<script language="Javascript">
|
|
||||||
<!--
|
|
||||||
function PopupCenter(page, width, height, options) {
|
|
||||||
var top=(screen.height-height)/2;
|
|
||||||
var left=(screen.width-width)/2;
|
|
||||||
window.open(page,\'Take a Thumbnail\',\'top=\'+top+\',left=\'+left+\',width=\'+width+\',height=\'+height+\',\'+options);
|
|
||||||
}
|
|
||||||
// -->
|
|
||||||
</script>';
|
|
||||||
echo '<ul style="margin-top: 0px"><li>' . htmlspecialchars($pic_info->name). '</li>
|
|
||||||
|
|
||||||
<li><a href="#" onclick="PopupCenter(\'' . $url . '\', 500, 400, \'toolbar=no, menubar=no, location=no, status=no\');" >'.__('Take a Thumbnail', 'facethumb').'</a></li>
|
|
||||||
<li><a href="'. $thumb_url. '">'.__('Thumb Gallery', 'facethumb').'</a></li>
|
|
||||||
</ul>';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
echo '<ul>
|
|
||||||
<li><a href="#" onclick="PopupCenter(\'' . $url . '\', 500, 400, \'toolbar=no, menubar=no, location=no, status=no\');" >'.__('Take a Thumbnail', 'facethumb').'</a></li>
|
|
||||||
<li><a href="'. $thumb_url . '">'.__('Thumb Gallery', 'facethumb').'</a></li>
|
|
||||||
</ul>';
|
|
||||||
}
|
|
||||||
echo $args['after_widget'];
|
|
||||||
}
|
|
||||||
|
|
||||||
function register(){
|
|
||||||
register_sidebar_widget('FaceThumb', array('FaceThumb', 'display_plugin'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Panel Admin
|
|
||||||
|
|
||||||
function facethumb_menu() {
|
|
||||||
add_menu_page('FaceThumb Options', 'FaceThumb', 10, __FILE__, 'facethumb_option');
|
|
||||||
add_submenu_page(__FILE__,'FaceThumb Options',__('Options', 'facethumb'), 10, __FILE__,'facethumb_option');
|
|
||||||
add_submenu_page(__FILE__,'Manage Gallery', __('Manage Gallery', 'facethumb'), 10, 'manage-gallery','manage_gallery');
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action('admin_menu', 'facethumb_menu');
|
|
||||||
|
|
||||||
function facethumb_option() {
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
$post = $wpdb->prefix . "posts";
|
|
||||||
$opt_val = get_option('facethumb_column');
|
|
||||||
$opt_val2 = get_option('facethumb_line');
|
|
||||||
$opt_val3 = get_option('facethumb_widget');
|
|
||||||
$opt_val4 = get_option('facethumb_link');
|
|
||||||
|
|
||||||
if( $_POST[ 'submit_hidden' ] == 'Y' ) {
|
|
||||||
function isInt($x) {
|
|
||||||
return(is_numeric($x) ? intval(0+$x) == $x : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isInt($_POST['facethumb_column']) AND $_POST['facethumb_column'] > 0 AND isInt($_POST['facethumb_line']) AND $_POST['facethumb_line'] > 0 ) {
|
|
||||||
$opt_val = $_POST['facethumb_column'];
|
|
||||||
update_option('facethumb_column', $opt_val);
|
|
||||||
|
|
||||||
$opt_val2 = $_POST['facethumb_line'];
|
|
||||||
update_option('facethumb_line', $opt_val2);
|
|
||||||
|
|
||||||
$opt_val3 = $_POST['facethumb_widget'];
|
|
||||||
update_option('facethumb_widget', $opt_val3);
|
|
||||||
|
|
||||||
$opt_val4 = $_POST['facethumb_link'];
|
|
||||||
update_option('facethumb_link', $opt_val4);
|
|
||||||
|
|
||||||
?>
|
|
||||||
<div class="updated"><p><strong><?php _e('Option saved', 'facethumb'); ?></strong></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
?>
|
|
||||||
<div class="updated"><p><strong><?php _e('Warning: Number of column and line are integer greater than 0.', 'facethumb'); ?></strong></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<div class="wrap">';
|
|
||||||
echo "<h2>" . __('FaceThumb Options', 'facethumb') . "</h2>";
|
|
||||||
?>
|
|
||||||
|
|
||||||
<form name="form1" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
|
|
||||||
<input type="hidden" name="submit_hidden" value="Y">
|
|
||||||
|
|
||||||
<h3><?php _e('Gallery properties', 'facethumb'); ?></h3>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<label for="facethumb_column" /><?php _e('Number of column for the gallery:', 'facethumb'); ?></label>
|
|
||||||
<input type="text" name="facethumb_column" id="facethumb_column" value="<?php echo $opt_val; ?>" size="10" />
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<label for="facethumb_line" /><?php _e('Number of line for the gallery:', 'facethumb'); ?></label>
|
|
||||||
<input type="text" name="facethumb_line" id="facethumb_line" value="<?php echo $opt_val2; ?>" size="10" />
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3><?php _e('Other Options', 'facethumb'); ?></h3>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<label for="facethumb_widget" /><?php _e('Photo to display in widget:', 'facethumb'); ?></label>
|
|
||||||
<select name="facethumb_widget" id="facethumb_widget">
|
|
||||||
<option value="last" <?php if($opt_val3 == "last") { echo 'selected="selected"'; } ?>><?php _e('The last one', 'facethumb'); ?></option>
|
|
||||||
<option value="random" <?php if($opt_val3 == "random") { echo 'selected="selected"'; } ?>><?php _e('A random one', 'facethumb'); ?></option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<label for="facethumb_link" /><?php _e('Display user\'s link with photos:', 'facethumb'); ?></label>
|
|
||||||
<select name="facethumb_link" id="facethumb_link">
|
|
||||||
<option value="gallery" <?php if($opt_val4 == "gallery") { echo 'selected="selected"'; } ?>><?php _e('Gallery', 'facethumb'); ?></option>
|
|
||||||
<option value="widget" <?php if($opt_val4 == "widget") { echo 'selected="selected"'; } ?>><?php _e('Widget', 'facethumb'); ?></option>
|
|
||||||
<option value="both" <?php if($opt_val4 == "both") { echo 'selected="selected"'; } ?>><?php _e('Both', 'facethumb'); ?></option>
|
|
||||||
<option value="none" <?php if($opt_val4 == "none") { echo 'selected="selected"'; } ?>><?php _e('None', 'facethumb'); ?></option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p class="submit">
|
|
||||||
<input type="submit" name="Submit" value="<?php _e('Update Options', 'facethumb'); ?>" />
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function manage_gallery() {
|
|
||||||
global $wpdb;
|
|
||||||
$plugin = $wpdb->prefix . "facethumb";
|
|
||||||
if ( $_POST['delete_hidden'] == 'Y' ) {
|
|
||||||
$startH = $_POST['start_hidden'] - 1; // les limit des BDD commencent à 0 donc on retire 1
|
|
||||||
$number_of_photo = $wpdb->get_var( "SELECT COUNT(*) FROM $plugin" );
|
|
||||||
$photo_per_page = get_option( 'facethumb_column' ) * get_option( 'facethumb_line' );
|
|
||||||
if ( $number_of_photo < $photo_per_page ) {
|
|
||||||
$stopH = $number_of_photo - 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$stopH = $startH + $photo_per_page - 1; // les limit des BDD commencent à 0 donc 1 pour $photo_per_page (pour $startH c'est deja fait)
|
|
||||||
} // Attention les photos de la gallerie sont affichées dans l'ordre décroissant
|
|
||||||
$idStartH = $wpdb->get_var( "SELECT id FROM $plugin ORDER BY id DESC LIMIT $startH, 1" );
|
|
||||||
$idStopH = $wpdb->get_var( "SELECT id FROM $plugin ORDER BY id DESC LIMIT $stopH, 1" );
|
|
||||||
$count = 0;
|
|
||||||
for ( $i = $idStopH; $i <= $idStartH; $i++ ) {
|
|
||||||
$dir = '../wp-content/plugins/facethumb/uploads/';
|
|
||||||
if ( $i == 1 AND $_POST['delete_1'] ) {
|
|
||||||
if(file_exists($dir.'mnt-tech.jpg')){
|
|
||||||
if (unlink($dir.'mnt-tech.jpg')) {
|
|
||||||
$wpdb->query( "DELETE FROM $plugin WHERE id='$i'" );
|
|
||||||
$count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ( $_POST['delete_'. $i] ) {
|
|
||||||
$thumb_to_delete = $wpdb->get_row( "SELECT * FROM $plugin WHERE id='".$i."'" );
|
|
||||||
if(file_exists($dir.$thumb_to_delete->time.'.jpg')){
|
|
||||||
if (unlink($dir.$thumb_to_delete->time.'.jpg')) {
|
|
||||||
$wpdb->query( "DELETE FROM $plugin WHERE id='$i'" );
|
|
||||||
$count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$wpdb->query( "DELETE FROM $plugin WHERE id='$i'" );
|
|
||||||
$count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo '<div class="wrap">';
|
|
||||||
echo "<h2>" . __('Manage Gallery', 'facethumb') . "</h2>";
|
|
||||||
if ($count > 0) {
|
|
||||||
echo '<div class="updated"><p><strong>' . $count . __(' thumbnail(s) deleted.', 'facethumb') . '</strong></p></div>';
|
|
||||||
}
|
|
||||||
echo calculate_gallery(1);
|
|
||||||
echo '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fin pannel Admin
|
|
||||||
|
|
||||||
function public_display_gallery() {
|
|
||||||
return calculate_gallery(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function modify_gallery_title($a) {
|
|
||||||
if ( $a == 'FaceThumb Gallery' ) {
|
|
||||||
return __('FaceThumb Gallery', 'facethumb');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return $a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function display_gallery () {
|
|
||||||
add_filter('the_title', 'modify_gallery_title');
|
|
||||||
if ( is_page('FaceThumb Gallery') ) {
|
|
||||||
add_filter('the_content', 'public_display_gallery' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action( 'loop_start', 'display_gallery' );
|
|
||||||
|
|
||||||
if ( isset( $_GET['name']) AND isset( $_GET['link']) AND isset( $_GET['url']) AND isset( $_GET['time'])) {
|
|
||||||
global $wpdb;
|
|
||||||
$table_name = $wpdb->prefix . "facethumb";
|
|
||||||
$link = mysql_real_escape_string(htmlspecialchars($_GET['link']));
|
|
||||||
$name = mysql_real_escape_string(htmlspecialchars($_GET['name']));
|
|
||||||
$time = mysql_real_escape_string(htmlspecialchars($_GET['time']));
|
|
||||||
$url = mysql_real_escape_string(htmlspecialchars($_GET['url']));
|
|
||||||
$wpdb->query( "INSERT INTO $table_name VALUES ('', '$time', '$name', '$url', '$link')");
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
require('../../../wp-blog-header.php');
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="fr-FR">
|
|
||||||
|
|
||||||
<head profile="http://gmpg.org/xfn/11">
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
||||||
<title><?php _e('Take a snapshot', 'facethumb'); ?></title>
|
|
||||||
<style type="text/css">
|
|
||||||
body {
|
|
||||||
margin: 0px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<?php
|
|
||||||
$swf = get_bloginfo('url'). '/wp-content/plugins/facethumb/Plugin.swf';
|
|
||||||
$upload = get_bloginfo('url'). '/wp-content/plugins/facethumb/upload.php';
|
|
||||||
?>
|
|
||||||
|
|
||||||
<object id="top_menu" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="500" height="400">
|
|
||||||
<param name="movie" value="<?php echo $swf; ?>" />
|
|
||||||
<param name="flashvars" value="upload=<?php echo $upload; ?>" />
|
|
||||||
<!--[if !IE]>-->
|
|
||||||
<object type="application/x-shockwave-flash" data="<?php echo $swf; ?>" width="500" height="400">
|
|
||||||
<param name="flashvars" value="upload=<?php echo $upload; ?>" />
|
|
||||||
<!--<![endif]-->
|
|
||||||
|
|
||||||
<!--[if !IE]>-->
|
|
||||||
</object>
|
|
||||||
<!--<![endif]-->
|
|
||||||
</object>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@ -1,137 +0,0 @@
|
|||||||
msgid ""
|
|
||||||
msgstr ""
|
|
||||||
"Project-Id-Version: \n"
|
|
||||||
"POT-Creation-Date: \n"
|
|
||||||
"PO-Revision-Date: \n"
|
|
||||||
"Last-Translator: MNT-Tech <contact@mnt-tech.fr>\n"
|
|
||||||
"Language-Team: \n"
|
|
||||||
"MIME-Version: 1.0\n"
|
|
||||||
"Content-Type: text/plain; charset=utf-8\n"
|
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
|
||||||
|
|
||||||
# SOME DESCRIPTIVE TITLE.
|
|
||||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
|
||||||
# This file is distributed under the same license as the PACKAGE package.
|
|
||||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
||||||
#
|
|
||||||
#: facethumb.php:35
|
|
||||||
msgid "Sorry, no photos have been taken yet!"
|
|
||||||
msgstr "Désolé, aucune photo n'a été prise!"
|
|
||||||
|
|
||||||
#: facethumb.php:64
|
|
||||||
#: facethumb.php:102
|
|
||||||
msgid "by "
|
|
||||||
msgstr "par "
|
|
||||||
|
|
||||||
#: facethumb.php:64
|
|
||||||
#: facethumb.php:102
|
|
||||||
msgid "the "
|
|
||||||
msgstr "le "
|
|
||||||
|
|
||||||
#: facethumb.php:64
|
|
||||||
#: facethumb.php:102
|
|
||||||
msgid " at "
|
|
||||||
msgstr " à "
|
|
||||||
|
|
||||||
#: facethumb.php:130
|
|
||||||
#: facethumb.php:133
|
|
||||||
#: facethumb.php:145
|
|
||||||
#: facethumb.php:155
|
|
||||||
#: facethumb.php:166
|
|
||||||
msgid "Pages"
|
|
||||||
msgstr "Pages"
|
|
||||||
|
|
||||||
#: facethumb.php:180
|
|
||||||
msgid "Delete Thumbnails"
|
|
||||||
msgstr "Supprimer les photos"
|
|
||||||
|
|
||||||
#: facethumb.php:270
|
|
||||||
#: facethumb.php:276
|
|
||||||
msgid "Take a Thumbnail"
|
|
||||||
msgstr "Prendre une photo"
|
|
||||||
|
|
||||||
#: facethumb.php:271
|
|
||||||
#: facethumb.php:277
|
|
||||||
msgid "Thumb Gallery"
|
|
||||||
msgstr "Galerie FaceThumb"
|
|
||||||
|
|
||||||
#: facethumb.php:326
|
|
||||||
msgid "Option saved"
|
|
||||||
msgstr "Options enregistrées"
|
|
||||||
|
|
||||||
#: facethumb.php:331
|
|
||||||
msgid "Warning: Number of column and line are integer greater than 0."
|
|
||||||
msgstr "Attention: Les nombres de ligne et de colonne doivent être des entriers supérieur à 0."
|
|
||||||
|
|
||||||
#: facethumb.php:338
|
|
||||||
msgid "FaceThumb Options"
|
|
||||||
msgstr "Options FaceThumb"
|
|
||||||
|
|
||||||
#: facethumb.php:344
|
|
||||||
msgid "Gallery properties"
|
|
||||||
msgstr "Propriétés de la galerie"
|
|
||||||
|
|
||||||
#: facethumb.php:347
|
|
||||||
msgid "Number of column for the gallery:"
|
|
||||||
msgstr "Nombre de colonnes pour la galerie: "
|
|
||||||
|
|
||||||
#: facethumb.php:352
|
|
||||||
msgid "Number of line for the gallery:"
|
|
||||||
msgstr "Nombre de lignes pour la galerie: "
|
|
||||||
|
|
||||||
#: facethumb.php:356
|
|
||||||
msgid "Other Options"
|
|
||||||
msgstr "Autres Options"
|
|
||||||
|
|
||||||
#: facethumb.php:359
|
|
||||||
msgid "Photo to display in widget:"
|
|
||||||
msgstr "Photo à afficher dans le widget: "
|
|
||||||
|
|
||||||
#: facethumb.php:361
|
|
||||||
msgid "The last one"
|
|
||||||
msgstr "La dernière"
|
|
||||||
|
|
||||||
#: facethumb.php:362
|
|
||||||
msgid "A random one"
|
|
||||||
msgstr "Une au hasard"
|
|
||||||
|
|
||||||
#: facethumb.php:368
|
|
||||||
msgid "Display user's link with photos:"
|
|
||||||
msgstr "Afficher les liens avec les photos des visiteurs: "
|
|
||||||
|
|
||||||
#: facethumb.php:370
|
|
||||||
msgid "Gallery"
|
|
||||||
msgstr "Galerie"
|
|
||||||
|
|
||||||
#: facethumb.php:371
|
|
||||||
msgid "Widget"
|
|
||||||
msgstr "Widget"
|
|
||||||
|
|
||||||
#: facethumb.php:372
|
|
||||||
msgid "Both"
|
|
||||||
msgstr "Les deux"
|
|
||||||
|
|
||||||
#: facethumb.php:373
|
|
||||||
msgid "None"
|
|
||||||
msgstr "Aucun"
|
|
||||||
|
|
||||||
#: facethumb.php:379
|
|
||||||
msgid "Update Options"
|
|
||||||
msgstr "Mettre à jour les options"
|
|
||||||
|
|
||||||
#: facethumb.php:431
|
|
||||||
msgid "Manage Gallery"
|
|
||||||
msgstr "Gestion de la galerie"
|
|
||||||
|
|
||||||
#: facethumb.php:433
|
|
||||||
msgid " thumbnail(s) deleted."
|
|
||||||
msgstr " photo(s) supprimée(s)."
|
|
||||||
|
|
||||||
#: facethumb.php:447
|
|
||||||
msgid "FaceThumb Gallery"
|
|
||||||
msgstr "Galerie FaceThumb"
|
|
||||||
|
|
||||||
#: flash.php:10
|
|
||||||
msgid "Take a snapshot"
|
|
||||||
msgstr "Ajoutez votre photo"
|
|
||||||
|
|
||||||
@ -1,129 +0,0 @@
|
|||||||
# SOME DESCRIPTIVE TITLE.
|
|
||||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
|
||||||
# This file is distributed under the same license as the PACKAGE package.
|
|
||||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
||||||
#
|
|
||||||
#, fuzzy
|
|
||||||
msgid ""
|
|
||||||
msgstr ""
|
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
|
||||||
"Report-Msgid-Bugs-To: \n"
|
|
||||||
"POT-Creation-Date: 2009-08-07 15:37+0200\n"
|
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
||||||
"MIME-Version: 1.0\n"
|
|
||||||
"Content-Type: text/plain; charset=CHARSET\n"
|
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
|
||||||
|
|
||||||
#: facethumb.php:35
|
|
||||||
msgid "Sorry, no photos have been taken yet!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:64 facethumb.php:102
|
|
||||||
msgid "by "
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:64 facethumb.php:102
|
|
||||||
msgid "the "
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:64 facethumb.php:102
|
|
||||||
msgid " at "
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:130 facethumb.php:133 facethumb.php:145 facethumb.php:155 facethumb.php:166
|
|
||||||
msgid "Pages"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:180
|
|
||||||
msgid "Delete Thumbnails"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:270 facethumb.php:276
|
|
||||||
msgid "Take a Thumbnail"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:271 facethumb.php:277
|
|
||||||
msgid "Thumb Gallery"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:326
|
|
||||||
msgid "Option saved"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:331
|
|
||||||
msgid "Warning: Number of column and line are integer greater than 0."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:338
|
|
||||||
msgid "FaceThumb Options"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:344
|
|
||||||
msgid "Gallery properties"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:347
|
|
||||||
msgid "Number of column for the gallery:"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:352
|
|
||||||
msgid "Number of line for the gallery:"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:356
|
|
||||||
msgid "Other Options"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:359
|
|
||||||
msgid "Photo to display in widget:"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:361
|
|
||||||
msgid "The last one"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:362
|
|
||||||
msgid "A random one"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:368
|
|
||||||
msgid "Display user's link with photos:"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:370
|
|
||||||
msgid "Gallery"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:371
|
|
||||||
msgid "Widget"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:372
|
|
||||||
msgid "Both"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:373
|
|
||||||
msgid "None"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:379
|
|
||||||
msgid "Update Options"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:431
|
|
||||||
msgid "Manage Gallery"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:433
|
|
||||||
msgid " thumbnail(s) deleted."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: facethumb.php:447
|
|
||||||
msgid "FaceThumb Gallery"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: flash.php:10
|
|
||||||
msgid "Take a snapshot"
|
|
||||||
msgstr ""
|
|
||||||
@ -1,75 +0,0 @@
|
|||||||
=== Facethumb ===
|
|
||||||
Contributors: mnttech
|
|
||||||
Donate link: http://www.mnt-tech.fr/blog
|
|
||||||
Tags: thumb, face, webcam, snapme, trombiblog, cam, facethumb, snapshot, widget
|
|
||||||
Requires at least: 2.7.0
|
|
||||||
Tested up to: 2.8.4
|
|
||||||
Stable tag: trunk
|
|
||||||
|
|
||||||
The plugin allows your visitor to post thumbnail on your blog
|
|
||||||
|
|
||||||
== Description ==
|
|
||||||
|
|
||||||
This plugin allows your visitor to take a snapshot whith a webcam and the thumb is display on your sidebar. The visitor indicate his pseudo and can let an URL which will be link to the thumb. You can see a demo at http://www.wordpress.mnt-tech.fr
|
|
||||||
|
|
||||||
French translation :
|
|
||||||
Ce plugin permet à vos visiteurs de prendre une photo avec leur webcam et cette photo sera affichée dans votre sidebar. Le visiteur indique son pseudo et peut également laisser une URL qui sera lié à la photo. Un démo est disponnible à l'adresse suivante: http://www.wordpress.mnt-tech.fr
|
|
||||||
|
|
||||||
== Installation ==
|
|
||||||
|
|
||||||
1. Simply download the archive of the latest release of facethumb
|
|
||||||
2. Go to the admin panel of your blog
|
|
||||||
3. Go to 'Add new' in the Plugins menu
|
|
||||||
4. Go to 'Upload' an click 'browse' to select the archive you've just downloaded
|
|
||||||
5. Click on the 'install now' button and here it is, facethumb is installed
|
|
||||||
6. To see it in action on your blog you just have to activate the widget in the widget menu which is in 'Appearance'
|
|
||||||
7. Just drag and drop facethumb in your sidebar and that's it. If you don't want to use the widgetized sidebar add `<?php FaceThumb::display_plugins($arg); ?>` to sidebar.php where you want the widget to be.
|
|
||||||
|
|
||||||
== Frequently Asked Questions ==
|
|
||||||
|
|
||||||
= Can I delete some strange thumb people posted on my blog? =
|
|
||||||
Yes, but that will be possible only if you have FaceThumb 0.0.3 or better.
|
|
||||||
= How do I add the widget in my sidebar? =
|
|
||||||
You can use 2 differents ways. Either go to 'Appearance' > 'Widget' in the admin panel and drag and drop FaceThumb from Available Widget to Sidebar 1 or add `<?php FaceThumb::display_plugins($arg); ?>` to sidebar.php file of your theme, where you want the widget to be
|
|
||||||
|
|
||||||
== Screenshots ==
|
|
||||||
|
|
||||||
1. The plugin is dispalyed in the sidebar. You can click on 'Take a thumbnail' or 'Thumb gallery' to use the plugin.
|
|
||||||
2. You just have to click on allow to let the site use your webcam
|
|
||||||
3. Just fill the form and click the snap button
|
|
||||||
|
|
||||||
== Changelog ==
|
|
||||||
|
|
||||||
= 0.0.4 =
|
|
||||||
|
|
||||||
* Adding some properties in the admin panel.
|
|
||||||
* Correcting some bugs.
|
|
||||||
* Installing I18n tools for the plugin (Languages available: English and French).
|
|
||||||
* Adding a property that allow you to see a preview before posting your thumbnail.
|
|
||||||
* Allowing user who do not have URL to share to use the plugin.
|
|
||||||
* Changing the way that the photo in the widget is displayed.
|
|
||||||
|
|
||||||
= 0.0.3 =
|
|
||||||
|
|
||||||
* Correcting some bugs of the gallery.
|
|
||||||
* Creating an administration panel to define gallery proprieties.
|
|
||||||
* Creating an administration panel to manage gallery (delete some thumb).
|
|
||||||
* Adding the plugin to the SVN repository.
|
|
||||||
|
|
||||||
= 0.0.2 =
|
|
||||||
|
|
||||||
* Snap button is now at the bottom (wich is more logic).
|
|
||||||
* You can only take shots, one by one.
|
|
||||||
* The windows is closed after you clicked on the OK button.
|
|
||||||
* The blog is refreshed after the snapshot is sent. (in order to see directly your ugly face).
|
|
||||||
* Better integration for Microsoft IE.
|
|
||||||
* Better widget intergration to increase adaptibility of the plugin in differents themes.
|
|
||||||
* Fix a security problem .
|
|
||||||
|
|
||||||
= 0.0.1 =
|
|
||||||
|
|
||||||
* First realease of facethumb.
|
|
||||||
|
|
||||||
== Arbitrary section ==
|
|
||||||
|
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 46 KiB |
@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
$time = time();
|
|
||||||
$sContent = file_get_contents('php://input');
|
|
||||||
$sName = 'uploads/' . $time . '.jpg';
|
|
||||||
file_put_contents($sName,$sContent);
|
|
||||||
$image_test = getimagesize($sName);
|
|
||||||
if ( $image_test['mime'] == "image/jpeg" ) {
|
|
||||||
$domaine = 'http://' . $_SERVER['SERVER_NAME'];
|
|
||||||
$self = $_SERVER["PHP_SELF"];
|
|
||||||
$base = str_replace( '/wp-content/plugins/facethumb/upload.php', '', $domaine.$self);
|
|
||||||
$link = $_GET['link'];
|
|
||||||
$name = $_GET['name'];
|
|
||||||
$url = str_replace( 'upload.php', $sName, $domaine.$self);
|
|
||||||
header("Location: ". $base ."/?name=". $name . "&link=" . $link . "&url=" . $url . "&time=" . $time);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
unlink($sName);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
@ -1,82 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @package Hello_Dolly
|
|
||||||
* @version 1.6
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
Plugin Name: Hello Dolly
|
|
||||||
Plugin URI: http://wordpress.org/extend/plugins/hello-dolly/
|
|
||||||
Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.
|
|
||||||
Author: Matt Mullenweg
|
|
||||||
Version: 1.6
|
|
||||||
Author URI: http://ma.tt/
|
|
||||||
*/
|
|
||||||
|
|
||||||
function hello_dolly_get_lyric() {
|
|
||||||
/** These are the lyrics to Hello Dolly */
|
|
||||||
$lyrics = "Hello, Dolly
|
|
||||||
Well, hello, Dolly
|
|
||||||
It's so nice to have you back where you belong
|
|
||||||
You're lookin' swell, Dolly
|
|
||||||
I can tell, Dolly
|
|
||||||
You're still glowin', you're still crowin'
|
|
||||||
You're still goin' strong
|
|
||||||
We feel the room swayin'
|
|
||||||
While the band's playin'
|
|
||||||
One of your old favourite songs from way back when
|
|
||||||
So, take her wrap, fellas
|
|
||||||
Find her an empty lap, fellas
|
|
||||||
Dolly'll never go away again
|
|
||||||
Hello, Dolly
|
|
||||||
Well, hello, Dolly
|
|
||||||
It's so nice to have you back where you belong
|
|
||||||
You're lookin' swell, Dolly
|
|
||||||
I can tell, Dolly
|
|
||||||
You're still glowin', you're still crowin'
|
|
||||||
You're still goin' strong
|
|
||||||
We feel the room swayin'
|
|
||||||
While the band's playin'
|
|
||||||
One of your old favourite songs from way back when
|
|
||||||
Golly, gee, fellas
|
|
||||||
Find her a vacant knee, fellas
|
|
||||||
Dolly'll never go away
|
|
||||||
Dolly'll never go away
|
|
||||||
Dolly'll never go away again";
|
|
||||||
|
|
||||||
// Here we split it into lines
|
|
||||||
$lyrics = explode( "\n", $lyrics );
|
|
||||||
|
|
||||||
// And then randomly choose a line
|
|
||||||
return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
// This just echoes the chosen line, we'll position it later
|
|
||||||
function hello_dolly() {
|
|
||||||
$chosen = hello_dolly_get_lyric();
|
|
||||||
echo "<p id='dolly'>$chosen</p>";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now we set that function up to execute when the admin_notices action is called
|
|
||||||
add_action( 'admin_notices', 'hello_dolly' );
|
|
||||||
|
|
||||||
// We need some CSS to position the paragraph
|
|
||||||
function dolly_css() {
|
|
||||||
// This makes sure that the positioning is also good for right-to-left languages
|
|
||||||
$x = is_rtl() ? 'left' : 'right';
|
|
||||||
|
|
||||||
echo "
|
|
||||||
<style type='text/css'>
|
|
||||||
#dolly {
|
|
||||||
float: $x;
|
|
||||||
padding-$x: 15px;
|
|
||||||
padding-top: 5px;
|
|
||||||
margin: 0;
|
|
||||||
font-size: 11px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
";
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action( 'admin_head', 'dolly_css' );
|
|
||||||
|
|
||||||
?>
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
#ltw_tes_quick_links {
|
|
||||||
text-align: right;
|
|
||||||
margin-top: -1.6em;
|
|
||||||
font-size: 0.9em;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.pagination {
|
|
||||||
padding: 3px;
|
|
||||||
margin: 3px;
|
|
||||||
text-align:center;
|
|
||||||
}
|
|
||||||
div.pagination a {
|
|
||||||
padding: 2px 5px 2px 5px;
|
|
||||||
margin: 2px;
|
|
||||||
border: 1px solid #AAAADD;
|
|
||||||
text-decoration: none;
|
|
||||||
color: #000099;
|
|
||||||
}
|
|
||||||
div.pagination a:hover, div.digg a:active {
|
|
||||||
border: 1px solid #000099;
|
|
||||||
color: #000;
|
|
||||||
}
|
|
||||||
div.pagination span.current {
|
|
||||||
padding: 2px 5px 2px 5px;
|
|
||||||
margin: 2px;
|
|
||||||
border: 1px solid #000099;
|
|
||||||
font-weight: bold;
|
|
||||||
background-color: #000099;
|
|
||||||
color: #FFF;
|
|
||||||
}
|
|
||||||
div.pagination span.disabled {
|
|
||||||
padding: 2px 5px 2px 5px;
|
|
||||||
margin: 2px;
|
|
||||||
border: 1px solid #EEE;
|
|
||||||
color: #DDD;
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 802 B |
|
Before Width: | Height: | Size: 2.0 KiB |
@ -1,45 +0,0 @@
|
|||||||
jQuery(document).ready(function($) {
|
|
||||||
$('.ltw_tes_show_in_widget').click(function(){
|
|
||||||
var clicked_id = $(this).val();
|
|
||||||
var item_checked = false;
|
|
||||||
|
|
||||||
$('#ltw_waiting_'+clicked_id).show();
|
|
||||||
|
|
||||||
if ($(this).attr("checked") == true) {
|
|
||||||
item_checked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.post(
|
|
||||||
ltw_tes_ajax.ajaxurl,
|
|
||||||
{
|
|
||||||
action: 'ltw_tes_widget_visible',
|
|
||||||
id: $(this).val(),
|
|
||||||
nonce: ltw_tes_ajax.nonce,
|
|
||||||
checked: item_checked
|
|
||||||
},
|
|
||||||
function(data) {
|
|
||||||
if (data == clicked_id) {
|
|
||||||
$('#ltw_waiting_'+clicked_id).hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.ltw_tes_update').click(function(){
|
|
||||||
var clicked_id = $(this).attr('id');
|
|
||||||
$('#waiting_order_'+clicked_id).show();
|
|
||||||
|
|
||||||
$.post(
|
|
||||||
ltw_tes_ajax.ajaxurl,
|
|
||||||
{
|
|
||||||
action: 'ltw_tes_update_order',
|
|
||||||
id: clicked_id.replace("update_", ""),
|
|
||||||
nonce: ltw_tes_ajax.nonce,
|
|
||||||
order: $('#order_'+clicked_id).val()
|
|
||||||
},
|
|
||||||
function(data) {
|
|
||||||
$('#waiting_order_'+clicked_id).hide();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,720 +0,0 @@
|
|||||||
// JS QuickTags version 1.3.1
|
|
||||||
//
|
|
||||||
// Copyright (c) 2002-2008 Alex King
|
|
||||||
// http://alexking.org/projects/js-quicktags
|
|
||||||
//
|
|
||||||
// Thanks to Greg Heo <greg@node79.com> for his changes
|
|
||||||
// to support multiple toolbars per page.
|
|
||||||
//
|
|
||||||
// Licensed under the LGPL license
|
|
||||||
// http://www.gnu.org/copyleft/lesser.html
|
|
||||||
//
|
|
||||||
// **********************************************************************
|
|
||||||
// This program is distributed in the hope that it will be useful, but
|
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
// **********************************************************************
|
|
||||||
//
|
|
||||||
// This JavaScript will insert the tags below at the cursor position in IE and
|
|
||||||
// Gecko-based browsers (Mozilla, Camino, Firefox, Netscape). For browsers that
|
|
||||||
// do not support inserting at the cursor position (older versions of Safari,
|
|
||||||
// OmniWeb) it appends the tags to the end of the content.
|
|
||||||
//
|
|
||||||
// Pass the ID of the <textarea> element to the edToolbar and function.
|
|
||||||
//
|
|
||||||
// Example:
|
|
||||||
//
|
|
||||||
// <script type="text/javascript">edToolbar('canvas');</script>
|
|
||||||
// <textarea id="canvas" rows="20" cols="50"></textarea>
|
|
||||||
//
|
|
||||||
|
|
||||||
var dictionaryUrl = 'http://www.ninjawords.com/';
|
|
||||||
|
|
||||||
// other options include:
|
|
||||||
//
|
|
||||||
// var dictionaryUrl = 'http://www.answers.com/';
|
|
||||||
// var dictionaryUrl = 'http://www.dictionary.com/';
|
|
||||||
|
|
||||||
var edButtons = new Array();
|
|
||||||
var edLinks = new Array();
|
|
||||||
var edOpenTags = new Array();
|
|
||||||
|
|
||||||
function edButton(id, display, tagStart, tagEnd, access, open) {
|
|
||||||
this.id = id; // used to name the toolbar button
|
|
||||||
this.display = display; // label on button
|
|
||||||
this.tagStart = tagStart; // open tag
|
|
||||||
this.tagEnd = tagEnd; // close tag
|
|
||||||
this.access = access; // set to -1 if tag does not need to be closed
|
|
||||||
this.open = open; // set to -1 if tag does not need to be closed
|
|
||||||
}
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_bold'
|
|
||||||
,'Bold'
|
|
||||||
,'<strong>'
|
|
||||||
,'</strong>'
|
|
||||||
,'b'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_italic'
|
|
||||||
,'Italic'
|
|
||||||
,'<em>'
|
|
||||||
,'</em>'
|
|
||||||
,'i'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_link'
|
|
||||||
,'Link'
|
|
||||||
,''
|
|
||||||
,'</a>'
|
|
||||||
,'a'
|
|
||||||
)
|
|
||||||
); // special case
|
|
||||||
|
|
||||||
/*edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_ext_link'
|
|
||||||
,'Ext. Link'
|
|
||||||
,''
|
|
||||||
,'</a>'
|
|
||||||
,'e'
|
|
||||||
)
|
|
||||||
); // special case
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_img'
|
|
||||||
,'IMG'
|
|
||||||
,''
|
|
||||||
,''
|
|
||||||
,'m'
|
|
||||||
,-1
|
|
||||||
)
|
|
||||||
); // special case
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_ul'
|
|
||||||
,'UL'
|
|
||||||
,'<ul>\n'
|
|
||||||
,'</ul>\n\n'
|
|
||||||
,'u'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_ol'
|
|
||||||
,'OL'
|
|
||||||
,'<ol>\n'
|
|
||||||
,'</ol>\n\n'
|
|
||||||
,'o'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_li'
|
|
||||||
,'LI'
|
|
||||||
,'\t<li>'
|
|
||||||
,'</li>\n'
|
|
||||||
,'l'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_block'
|
|
||||||
,'B-QUOTE'
|
|
||||||
,'<blockquote>'
|
|
||||||
,'</blockquote>'
|
|
||||||
,'q'
|
|
||||||
)
|
|
||||||
);*/
|
|
||||||
|
|
||||||
var extendedStart = edButtons.length;
|
|
||||||
|
|
||||||
// below here are the extended buttons
|
|
||||||
|
|
||||||
/*edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_h1'
|
|
||||||
,'H1'
|
|
||||||
,'<h1>'
|
|
||||||
,'</h1>\n\n'
|
|
||||||
,'1'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_h2'
|
|
||||||
,'H2'
|
|
||||||
,'<h2>'
|
|
||||||
,'</h2>\n\n'
|
|
||||||
,'2'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_h3'
|
|
||||||
,'H3'
|
|
||||||
,'<h3>'
|
|
||||||
,'</h3>\n\n'
|
|
||||||
,'3'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_h4'
|
|
||||||
,'H4'
|
|
||||||
,'<h4>'
|
|
||||||
,'</h4>\n\n'
|
|
||||||
,'4'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_p'
|
|
||||||
,'P'
|
|
||||||
,'<p>'
|
|
||||||
,'</p>\n\n'
|
|
||||||
,'p'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_code'
|
|
||||||
,'CODE'
|
|
||||||
,'<code>'
|
|
||||||
,'</code>'
|
|
||||||
,'c'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_pre'
|
|
||||||
,'PRE'
|
|
||||||
,'<pre>'
|
|
||||||
,'</pre>'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_dl'
|
|
||||||
,'DL'
|
|
||||||
,'<dl>\n'
|
|
||||||
,'</dl>\n\n'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_dt'
|
|
||||||
,'DT'
|
|
||||||
,'\t<dt>'
|
|
||||||
,'</dt>\n'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_dd'
|
|
||||||
,'DD'
|
|
||||||
,'\t<dd>'
|
|
||||||
,'</dd>\n'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_table'
|
|
||||||
,'TABLE'
|
|
||||||
,'<table>\n<tbody>'
|
|
||||||
,'</tbody>\n</table>\n'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_tr'
|
|
||||||
,'TR'
|
|
||||||
,'\t<tr>\n'
|
|
||||||
,'\n\t</tr>\n'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_td'
|
|
||||||
,'TD'
|
|
||||||
,'\t\t<td>'
|
|
||||||
,'</td>\n'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_ins'
|
|
||||||
,'INS'
|
|
||||||
,'<ins>'
|
|
||||||
,'</ins>'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_del'
|
|
||||||
,'DEL'
|
|
||||||
,'<del>'
|
|
||||||
,'</del>'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_nobr'
|
|
||||||
,'NOBR'
|
|
||||||
,'<nobr>'
|
|
||||||
,'</nobr>'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_footnote'
|
|
||||||
,'Footnote'
|
|
||||||
,''
|
|
||||||
,''
|
|
||||||
,'f'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
edButtons.push(
|
|
||||||
new edButton(
|
|
||||||
'ed_via'
|
|
||||||
,'Via'
|
|
||||||
,''
|
|
||||||
,''
|
|
||||||
,'v'
|
|
||||||
)
|
|
||||||
);*/
|
|
||||||
|
|
||||||
function edLink(display, URL, newWin) {
|
|
||||||
this.display = display;
|
|
||||||
this.URL = URL;
|
|
||||||
if (!newWin) {
|
|
||||||
newWin = 0;
|
|
||||||
}
|
|
||||||
this.newWin = newWin;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
edLinks[edLinks.length] = new edLink('google.com'
|
|
||||||
,'http://www.google.com/'
|
|
||||||
);
|
|
||||||
|
|
||||||
function edShowButton(which, button, i) {
|
|
||||||
if (button.access) {
|
|
||||||
var accesskey = ' accesskey = "' + button.access + '"'
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var accesskey = '';
|
|
||||||
}
|
|
||||||
switch (button.id) {
|
|
||||||
case 'ed_img':
|
|
||||||
document.write('<input type="button" id="' + button.id + '_' + which + '" ' + accesskey + ' class="ed_button" onclick="edInsertImage(\'' + which + '\');" value="' + button.display + '" />');
|
|
||||||
break;
|
|
||||||
case 'ed_link':
|
|
||||||
document.write('<input type="button" id="' + button.id + '_' + which + '" ' + accesskey + ' class="ed_button" onclick="edInsertLink(\'' + which + '\', ' + i + ');" value="' + button.display + '" />');
|
|
||||||
break;
|
|
||||||
case 'ed_ext_link':
|
|
||||||
document.write('<input type="button" id="' + button.id + '_' + which + '" ' + accesskey + ' class="ed_button" onclick="edInsertExtLink(\'' + which + '\', ' + i + ');" value="' + button.display + '" />');
|
|
||||||
break;
|
|
||||||
case 'ed_footnote':
|
|
||||||
document.write('<input type="button" id="' + button.id + '_' + which + '" ' + accesskey + ' class="ed_button" onclick="edInsertFootnote(\'' + which + '\');" value="' + button.display + '" />');
|
|
||||||
break;
|
|
||||||
case 'ed_via':
|
|
||||||
document.write('<input type="button" id="' + button.id + '_' + which + '" ' + accesskey + ' class="ed_button" onclick="edInsertVia(\'' + which + '\');" value="' + button.display + '" />');
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
document.write('<input type="button" id="' + button.id + '_' + which + '" ' + accesskey + ' class="ed_button" onclick="edInsertTag(\'' + which + '\', ' + i + ');" value="' + button.display + '" />');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edShowLinks() {
|
|
||||||
var tempStr = '<select onchange="edQuickLink(this.options[this.selectedIndex].value, this);"><option value="-1" selected>(Quick Links)</option>';
|
|
||||||
for (i = 0; i < edLinks.length; i++) {
|
|
||||||
tempStr += '<option value="' + i + '">' + edLinks[i].display + '</option>';
|
|
||||||
}
|
|
||||||
tempStr += '</select>';
|
|
||||||
document.write(tempStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
function edAddTag(which, button) {
|
|
||||||
if (edButtons[button].tagEnd != '') {
|
|
||||||
edOpenTags[which][edOpenTags[which].length] = button;
|
|
||||||
document.getElementById(edButtons[button].id + '_' + which).value = '/' + document.getElementById(edButtons[button].id + '_' + which).value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edRemoveTag(which, button) {
|
|
||||||
for (i = 0; i < edOpenTags[which].length; i++) {
|
|
||||||
if (edOpenTags[which][i] == button) {
|
|
||||||
edOpenTags[which].splice(i, 1);
|
|
||||||
document.getElementById(edButtons[button].id + '_' + which).value = document.getElementById(edButtons[button].id + '_' + which).value.replace('/', '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edCheckOpenTags(which, button) {
|
|
||||||
var tag = 0;
|
|
||||||
for (i = 0; i < edOpenTags[which].length; i++) {
|
|
||||||
if (edOpenTags[which][i] == button) {
|
|
||||||
tag++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tag > 0) {
|
|
||||||
return true; // tag found
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false; // tag not found
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edCloseAllTags(which) {
|
|
||||||
var count = edOpenTags[which].length;
|
|
||||||
for (o = 0; o < count; o++) {
|
|
||||||
edInsertTag(which, edOpenTags[which][edOpenTags[which].length - 1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edQuickLink(i, thisSelect) {
|
|
||||||
if (i > -1) {
|
|
||||||
var newWin = '';
|
|
||||||
if (edLinks[i].newWin == 1) {
|
|
||||||
newWin = ' target="_blank"';
|
|
||||||
}
|
|
||||||
var tempStr = '<a href="' + edLinks[i].URL + '"' + newWin + '>'
|
|
||||||
+ edLinks[i].display
|
|
||||||
+ '</a>';
|
|
||||||
thisSelect.selectedIndex = 0;
|
|
||||||
edInsertContent(edCanvas, tempStr);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
thisSelect.selectedIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edSpell(which) {
|
|
||||||
myField = document.getElementById(which);
|
|
||||||
var word = '';
|
|
||||||
if (document.selection) {
|
|
||||||
myField.focus();
|
|
||||||
var sel = document.selection.createRange();
|
|
||||||
if (sel.text.length > 0) {
|
|
||||||
word = sel.text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (myField.selectionStart || myField.selectionStart == '0') {
|
|
||||||
var startPos = myField.selectionStart;
|
|
||||||
var endPos = myField.selectionEnd;
|
|
||||||
if (startPos != endPos) {
|
|
||||||
word = myField.value.substring(startPos, endPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (word == '') {
|
|
||||||
word = prompt('Enter a word to look up:', '');
|
|
||||||
}
|
|
||||||
if (word != '') {
|
|
||||||
window.open(dictionaryUrl + escape(word));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edToolbar(which) {
|
|
||||||
document.write('<div id="ed_toolbar"><span>');
|
|
||||||
for (i = 0; i < extendedStart; i++) {
|
|
||||||
edShowButton(which, edButtons[i], i);
|
|
||||||
}
|
|
||||||
if (edShowExtraCookie()) {
|
|
||||||
document.write(
|
|
||||||
'<input type="button" id="ed_close_' + which + '" class="ed_button" onclick="edCloseAllTags(\'' + which + '\');" value="Close Tags" />'
|
|
||||||
//+ '<input type="button" id="ed_spell_' + which + '" class="ed_button" onclick="edSpell(\'' + which + '\');" value="Dict" />'
|
|
||||||
//+ '<input type="button" id="ed_extra_show_' + which + '" class="ed_button" onclick="edShowExtra(\'' + which + '\')" value="»" style="visibility: hidden;" />'
|
|
||||||
+ '</span><br />'
|
|
||||||
+ '<span id="ed_extra_buttons_' + which + '">'
|
|
||||||
+ '<input type="button" id="ed_extra_hide_' + which + '" class="ed_button" onclick="edHideExtra(\'' + which + '\');" value="«" />'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
document.write(
|
|
||||||
'<input type="button" id="ed_close_' + which + '" class="ed_button" onclick="edCloseAllTags(\'' + which + '\');" value="Close Tags" />'
|
|
||||||
//+ '<input type="button" id="ed_spell_' + which + '" class="ed_button" onclick="edSpell(\'' + which + '\');" value="Dict" />'
|
|
||||||
//+ '<input type="button" id="ed_extra_show_' + which + '" class="ed_button" onclick="edShowExtra(\'' + which + '\')" value="»" />'
|
|
||||||
+ '</span><br />'
|
|
||||||
+ '<span id="ed_extra_buttons_' + which + '" style="display: none;">'
|
|
||||||
+ '<input type="button" id="ed_extra_hide_' + which + '" class="ed_button" onclick="edHideExtra(\'' + which + '\');" value="«" />'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
for (i = extendedStart; i < edButtons.length; i++) {
|
|
||||||
edShowButton(which, edButtons[i], i);
|
|
||||||
}
|
|
||||||
document.write('</span>');
|
|
||||||
// edShowLinks();
|
|
||||||
document.write('</div>');
|
|
||||||
edOpenTags[which] = new Array();
|
|
||||||
}
|
|
||||||
|
|
||||||
function edShowExtra(which) {
|
|
||||||
document.getElementById('ed_extra_show_' + which).style.visibility = 'hidden';
|
|
||||||
document.getElementById('ed_extra_buttons_' + which).style.display = 'block';
|
|
||||||
edSetCookie(
|
|
||||||
'js_quicktags_extra'
|
|
||||||
, 'show'
|
|
||||||
, new Date("December 31, 2100")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function edHideExtra(which) {
|
|
||||||
document.getElementById('ed_extra_buttons_' + which).style.display = 'none';
|
|
||||||
document.getElementById('ed_extra_show_' + which).style.visibility = 'visible';
|
|
||||||
edSetCookie(
|
|
||||||
'js_quicktags_extra'
|
|
||||||
, 'hide'
|
|
||||||
, new Date("December 31, 2100")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// insertion code
|
|
||||||
|
|
||||||
function edInsertTag(which, i) {
|
|
||||||
myField = document.getElementById(which);
|
|
||||||
//IE support
|
|
||||||
if (document.selection) {
|
|
||||||
myField.focus();
|
|
||||||
sel = document.selection.createRange();
|
|
||||||
if (sel.text.length > 0) {
|
|
||||||
sel.text = edButtons[i].tagStart + sel.text + edButtons[i].tagEnd;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!edCheckOpenTags(which, i) || edButtons[i].tagEnd == '') {
|
|
||||||
sel.text = edButtons[i].tagStart;
|
|
||||||
edAddTag(which, i);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sel.text = edButtons[i].tagEnd;
|
|
||||||
edRemoveTag(which, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
myField.focus();
|
|
||||||
}
|
|
||||||
//MOZILLA/NETSCAPE support
|
|
||||||
else if (myField.selectionStart || myField.selectionStart == '0') {
|
|
||||||
var startPos = myField.selectionStart;
|
|
||||||
var endPos = myField.selectionEnd;
|
|
||||||
var cursorPos = endPos;
|
|
||||||
var scrollTop = myField.scrollTop;
|
|
||||||
if (startPos != endPos) {
|
|
||||||
myField.value = myField.value.substring(0, startPos)
|
|
||||||
+ edButtons[i].tagStart
|
|
||||||
+ myField.value.substring(startPos, endPos)
|
|
||||||
+ edButtons[i].tagEnd
|
|
||||||
+ myField.value.substring(endPos, myField.value.length);
|
|
||||||
cursorPos += edButtons[i].tagStart.length + edButtons[i].tagEnd.length;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!edCheckOpenTags(which, i) || edButtons[i].tagEnd == '') {
|
|
||||||
myField.value = myField.value.substring(0, startPos)
|
|
||||||
+ edButtons[i].tagStart
|
|
||||||
+ myField.value.substring(endPos, myField.value.length);
|
|
||||||
edAddTag(which, i);
|
|
||||||
cursorPos = startPos + edButtons[i].tagStart.length;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
myField.value = myField.value.substring(0, startPos)
|
|
||||||
+ edButtons[i].tagEnd
|
|
||||||
+ myField.value.substring(endPos, myField.value.length);
|
|
||||||
edRemoveTag(which, i);
|
|
||||||
cursorPos = startPos + edButtons[i].tagEnd.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
myField.focus();
|
|
||||||
myField.selectionStart = cursorPos;
|
|
||||||
myField.selectionEnd = cursorPos;
|
|
||||||
myField.scrollTop = scrollTop;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!edCheckOpenTags(which, i) || edButtons[i].tagEnd == '') {
|
|
||||||
myField.value += edButtons[i].tagStart;
|
|
||||||
edAddTag(which, i);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
myField.value += edButtons[i].tagEnd;
|
|
||||||
edRemoveTag(which, i);
|
|
||||||
}
|
|
||||||
myField.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edInsertContent(which, myValue) {
|
|
||||||
myField = document.getElementById(which);
|
|
||||||
//IE support
|
|
||||||
if (document.selection) {
|
|
||||||
myField.focus();
|
|
||||||
sel = document.selection.createRange();
|
|
||||||
sel.text = myValue;
|
|
||||||
myField.focus();
|
|
||||||
}
|
|
||||||
//MOZILLA/NETSCAPE support
|
|
||||||
else if (myField.selectionStart || myField.selectionStart == '0') {
|
|
||||||
var startPos = myField.selectionStart;
|
|
||||||
var endPos = myField.selectionEnd;
|
|
||||||
var scrollTop = myField.scrollTop;
|
|
||||||
myField.value = myField.value.substring(0, startPos)
|
|
||||||
+ myValue
|
|
||||||
+ myField.value.substring(endPos, myField.value.length);
|
|
||||||
myField.focus();
|
|
||||||
myField.selectionStart = startPos + myValue.length;
|
|
||||||
myField.selectionEnd = startPos + myValue.length;
|
|
||||||
myField.scrollTop = scrollTop;
|
|
||||||
} else {
|
|
||||||
myField.value += myValue;
|
|
||||||
myField.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edInsertLink(which, i, defaultValue) {
|
|
||||||
myField = document.getElementById(which);
|
|
||||||
if (!defaultValue) {
|
|
||||||
defaultValue = 'http://';
|
|
||||||
}
|
|
||||||
if (!edCheckOpenTags(which, i)) {
|
|
||||||
var URL = prompt('Enter the URL' ,defaultValue);
|
|
||||||
if (URL) {
|
|
||||||
edButtons[i].tagStart = '<a href="' + URL + '">';
|
|
||||||
edInsertTag(which, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
edInsertTag(which, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edInsertExtLink(which, i, defaultValue) {
|
|
||||||
myField = document.getElementById(which);
|
|
||||||
if (!defaultValue) {
|
|
||||||
defaultValue = 'http://';
|
|
||||||
}
|
|
||||||
if (!edCheckOpenTags(which, i)) {
|
|
||||||
var URL = prompt('Enter the URL' ,defaultValue);
|
|
||||||
if (URL) {
|
|
||||||
edButtons[i].tagStart = '<a href="' + URL + '" rel="external">';
|
|
||||||
edInsertTag(which, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
edInsertTag(which, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edInsertImage(which) {
|
|
||||||
myField = document.getElementById(which);
|
|
||||||
var myValue = prompt('Enter the URL of the image', 'http://');
|
|
||||||
if (myValue) {
|
|
||||||
myValue = '<img src="'
|
|
||||||
+ myValue
|
|
||||||
+ '" alt="' + prompt('Enter a description of the image', '')
|
|
||||||
+ '" />';
|
|
||||||
edInsertContent(which, myValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function edInsertFootnote(which) {
|
|
||||||
myField = document.getElementById(which);
|
|
||||||
var note = prompt('Enter the footnote:', '');
|
|
||||||
if (!note || note == '') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var now = new Date;
|
|
||||||
var fnId = 'fn' + now.getTime();
|
|
||||||
var fnStart = myField.value.indexOf('<ol class="footnotes">');
|
|
||||||
if (fnStart != -1) {
|
|
||||||
var fnStr1 = myField.value.substring(0, fnStart)
|
|
||||||
var fnStr2 = myField.value.substring(fnStart, myField.value.length)
|
|
||||||
var count = countInstances(fnStr2, '<li id="') + 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var count = 1;
|
|
||||||
}
|
|
||||||
var count = '<sup><a href="#' + fnId + 'n" id="' + fnId + '" class="footnote">' + count + '</a></sup>';
|
|
||||||
edInsertContent(which, count);
|
|
||||||
if (fnStart != -1) {
|
|
||||||
fnStr1 = myField.value.substring(0, fnStart + count.length)
|
|
||||||
fnStr2 = myField.value.substring(fnStart + count.length, myField.value.length)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var fnStr1 = myField.value;
|
|
||||||
var fnStr2 = "\n\n" + '<ol class="footnotes">' + "\n"
|
|
||||||
+ '</ol>' + "\n";
|
|
||||||
}
|
|
||||||
var footnote = ' <li id="' + fnId + 'n">' + note + ' [<a href="#' + fnId + '">back</a>]</li>' + "\n"
|
|
||||||
+ '</ol>';
|
|
||||||
myField.value = fnStr1 + fnStr2.replace('</ol>', footnote);
|
|
||||||
}
|
|
||||||
|
|
||||||
function countInstances(string, substr) {
|
|
||||||
var count = string.split(substr);
|
|
||||||
return count.length - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function edInsertVia(which) {
|
|
||||||
myField = document.getElementById(which);
|
|
||||||
var myValue = prompt('Enter the URL of the source link', 'http://');
|
|
||||||
if (myValue) {
|
|
||||||
myValue = '(Thanks <a href="' + myValue + '" rel="external">'
|
|
||||||
+ prompt('Enter the name of the source', '')
|
|
||||||
+ '</a>)';
|
|
||||||
edInsertContent(which, myValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function edSetCookie(name, value, expires, path, domain) {
|
|
||||||
document.cookie= name + "=" + escape(value) +
|
|
||||||
((expires) ? "; expires=" + expires.toGMTString() : "") +
|
|
||||||
((path) ? "; path=" + path : "") +
|
|
||||||
((domain) ? "; domain=" + domain : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
function edShowExtraCookie() {
|
|
||||||
var cookies = document.cookie.split(';');
|
|
||||||
for (var i=0;i < cookies.length; i++) {
|
|
||||||
var cookieData = cookies[i];
|
|
||||||
while (cookieData.charAt(0) ==' ') {
|
|
||||||
cookieData = cookieData.substring(1, cookieData.length);
|
|
||||||
}
|
|
||||||
if (cookieData.indexOf('js_quicktags_extra') == 0) {
|
|
||||||
if (cookieData.substring(19, cookieData.length) == 'show') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
jQuery(document).ready(function($) {
|
|
||||||
$('#upload_image_button').click(function() {
|
|
||||||
formfield = $('#upload_image').attr('name');
|
|
||||||
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
window.send_to_editor = function(html) {
|
|
||||||
imgurl = $('img',html).attr('src');
|
|
||||||
$('#upload_image').val(imgurl);
|
|
||||||
tb_remove();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@ -1,754 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
Plugin Name: LessThanWeb - Testimonials
|
|
||||||
Plugin URI: http://www.lessthanweb.com/products/wp-plugin-ltw-testimonials
|
|
||||||
Description: Display client testimonials on your blog. Easily manage client testimonials for different products on a single blog by separating them into groups.
|
|
||||||
Version: 1.3.0
|
|
||||||
Author: LessThanWeb
|
|
||||||
Author URI: http://www.lessthanweb.com
|
|
||||||
License: GPL2
|
|
||||||
*/
|
|
||||||
/* Copyright 2010 Anze Stokelj (email : wpplugins@lessthanweb.com)
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License, version 2, as
|
|
||||||
published by the Free Software Foundation.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
// Define some stuff for plugin..
|
|
||||||
define('LTW_TES_NAME', 'Testimonials');
|
|
||||||
define('LTW_TES_FOLDER_NAME', 'ltw-testimonials');
|
|
||||||
define('LTW_TES_VERSION', '1.2.1');
|
|
||||||
define('LTW_TES_TESTIMONIALS_TABLE', $wpdb->prefix.'ltw_testimonials');
|
|
||||||
define('LTW_TES_TESTIMONIAL_GROUPS_TABLE', $wpdb->prefix.'ltw_testimonial_groups');
|
|
||||||
define('LTW_TES_UNIQUE_NAME', 'ltw_testimonials');
|
|
||||||
|
|
||||||
require(WP_PLUGIN_DIR.'/'.LTW_TES_FOLDER_NAME.'/pages/ajax.php');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Install function.
|
|
||||||
* It creates required tables and adds version entry to settings table.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_tes_install()
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
if($wpdb->get_var("show tables like '".LTW_TES_TESTIMONIALS_TABLE."'") != LTW_TES_TESTIMONIALS_TABLE)
|
|
||||||
{
|
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS `".LTW_TES_TESTIMONIALS_TABLE."` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`group_id` INT NOT NULL DEFAULT '0',
|
|
||||||
`testimonial` text NOT NULL,
|
|
||||||
`client_name` varchar(250) NOT NULL,
|
|
||||||
`client_pic` VARCHAR(250) NOT NULL,
|
|
||||||
`client_website` varchar(250) NOT NULL,
|
|
||||||
`client_company` varchar(250) NOT NULL,
|
|
||||||
`order` int(5) NOT NULL DEFAULT '0',
|
|
||||||
`show_in_widget` TINYINT( 1 ) NOT NULL DEFAULT '0',
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=MyISAM AUTO_INCREMENT=1 ;";
|
|
||||||
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
|
||||||
dbDelta($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($wpdb->get_var("show tables like '".LTW_TES_TESTIMONIAL_GROUPS_TABLE."'") != LTW_TES_TESTIMONIAL_GROUPS_TABLE)
|
|
||||||
{
|
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`group_name` varchar(250) NOT NULL,
|
|
||||||
`page_id` INT(11) NOT NULL DEFAULT '0',
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=MyISAM AUTO_INCREMENT=1 ;";
|
|
||||||
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
|
||||||
dbDelta($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add current database version to option table.
|
|
||||||
// This is helpful for updates in case we have some table changes in future.
|
|
||||||
add_option('ltw_tes_version', LTW_TES_VERSION);
|
|
||||||
|
|
||||||
add_option('ltw_tes_sort_testimonials', '1', '', 'yes');
|
|
||||||
add_option('ltw_tes_delete_tables', '0', '', 'yes');
|
|
||||||
add_option('ltw_tes_design_css', '
|
|
||||||
.ltw_tes_item {
|
|
||||||
margin: 0 0 24px 0;
|
|
||||||
overflow: hidden;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.ltw_tes_image_cont {
|
|
||||||
float: left;
|
|
||||||
height: 88px;
|
|
||||||
margin: 4px 20px 0 5px;
|
|
||||||
width: 88px;
|
|
||||||
}
|
|
||||||
.ltw_tes_image_cont img {
|
|
||||||
border: 2px solid #CCCCCC;
|
|
||||||
}
|
|
||||||
.ltw_tes_content_cont {
|
|
||||||
float: left;
|
|
||||||
width: 330px;
|
|
||||||
}
|
|
||||||
.ltw_tes_content_cont p {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
.ltw_tes_testimonial {
|
|
||||||
color: #555555;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 21px;
|
|
||||||
margin: 0 0 12px;
|
|
||||||
}
|
|
||||||
.ltw_tes_client_name {
|
|
||||||
font-weight: bold;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
.ltw_tes_client_company {
|
|
||||||
margin: 0;
|
|
||||||
color: #00AEEF;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
.ltw_tes_client_company a {
|
|
||||||
color: #00AEEF;
|
|
||||||
font-size: 12px;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
.ltw_tes_client_company a:hover {
|
|
||||||
color: #555555;
|
|
||||||
}
|
|
||||||
', '', 'yes');
|
|
||||||
add_option('ltw_tes_design_html', '
|
|
||||||
<div class="ltw_tes_item">
|
|
||||||
<div class="ltw_tes_image_cont"><img src="%image%" alt=""/></div>
|
|
||||||
<div class="ltw_tes_content_cont">
|
|
||||||
<p class="ltw_tes_testimonial">%testimonial%</p>
|
|
||||||
<p class="ltw_tes_client_name">%client_name%</p>
|
|
||||||
<p class="ltw_tes_client_company">%client_company%</p>
|
|
||||||
</div>
|
|
||||||
</div>', '', 'yes');
|
|
||||||
|
|
||||||
add_option('ltw_tes_promote_plugin', '0', '', 'yes');
|
|
||||||
}
|
|
||||||
register_activation_hook(__FILE__, 'ltw_tes_install');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create admin menu
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_tes_menu_pages()
|
|
||||||
{
|
|
||||||
// Add a new top-level menu
|
|
||||||
add_menu_page(LTW_TES_NAME, LTW_TES_NAME, 'administrator', 'ltw_manage_testimonials', 'ltw_manage_testimonials', WP_PLUGIN_URL.'/ltw-testimonials/images/icon.png');
|
|
||||||
|
|
||||||
// Create subpages
|
|
||||||
$ltw_tes_testimonials_manage = add_submenu_page('ltw_manage_testimonials', LTW_TES_NAME.__(' - Manage', LTW_TES_UNIQUE_NAME), __('Testimonials', LTW_TES_UNIQUE_NAME), 'administrator', 'ltw_manage_testimonials', 'ltw_manage_testimonials');
|
|
||||||
$ltw_tes_testimonial_groups = add_submenu_page('ltw_manage_testimonials', LTW_TES_NAME.__(' - Groups', LTW_TES_UNIQUE_NAME), __('Groups', LTW_TES_UNIQUE_NAME), 'administrator', 'ltw_manage_testimonial_groups', 'ltw_manage_testimonial_groups');
|
|
||||||
$ltw_tes_testimonial_design = add_submenu_page('ltw_manage_testimonials', LTW_TES_NAME.__(' - Design', LTW_TES_UNIQUE_NAME), __('Design', LTW_TES_UNIQUE_NAME), 'administrator', 'ltw_manage_testimonial_design', 'ltw_manage_testimonial_design');
|
|
||||||
$ltw_tes_testimonial_settings = add_submenu_page('ltw_manage_testimonials', LTW_TES_NAME.__(' - Settings', LTW_TES_UNIQUE_NAME), __('Settings', LTW_TES_UNIQUE_NAME), 'administrator', 'ltw_tes_settings', 'ltw_tes_settings');
|
|
||||||
|
|
||||||
add_action('admin_print_styles-'.$ltw_tes_testimonials_manage, 'ltw_tes_admin_style');
|
|
||||||
add_action('admin_print_styles-'.$ltw_tes_testimonial_groups, 'ltw_tes_admin_style');
|
|
||||||
add_action('admin_print_styles-'.$ltw_tes_testimonial_design, 'ltw_tes_admin_style');
|
|
||||||
add_action('admin_print_styles-'.$ltw_tes_testimonial_settings, 'ltw_tes_admin_style');
|
|
||||||
|
|
||||||
// Register settings
|
|
||||||
add_action('admin_init', 'ltw_tes_register_settings');
|
|
||||||
}
|
|
||||||
// Call create admin menu function above
|
|
||||||
add_action('admin_menu', 'ltw_tes_menu_pages');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register settings
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_tes_register_settings()
|
|
||||||
{
|
|
||||||
register_setting('ltw-testimonials-settings', 'ltw_tes_sort_testimonials');
|
|
||||||
register_setting('ltw-testimonials-settings', 'ltw_tes_delete_tables');
|
|
||||||
register_setting('ltw-testimonials-settings', 'ltw_tes_promote_plugin');
|
|
||||||
|
|
||||||
register_setting('ltw-testimonials-design', 'ltw_tes_design_css');
|
|
||||||
register_setting('ltw-testimonials-design', 'ltw_tes_design_html');
|
|
||||||
|
|
||||||
if (get_option('ltw_tes_version') != LTW_TES_VERSION)
|
|
||||||
{
|
|
||||||
update_option('ltw_tes_version', LTW_TES_VERSION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main function for managing testimonials.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_manage_testimonials()
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
$current_testimonial_page = isset($_GET['sp']) ? $_GET['sp'] : '';
|
|
||||||
|
|
||||||
switch($current_testimonial_page)
|
|
||||||
{
|
|
||||||
case 'edit':
|
|
||||||
include('pages/testimonial_edit.php');
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Add new testimonial
|
|
||||||
case 'add_new':
|
|
||||||
include('pages/testimonial_add_new.php');
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Default page, table with all available testimonials
|
|
||||||
default:
|
|
||||||
include('pages/testimonial_index.php');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main function for managing testimonial groups
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_manage_testimonial_groups()
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
$current_testimonial_group_page = isset($_GET['sp']) ? $_GET['sp'] : '';
|
|
||||||
|
|
||||||
switch($current_testimonial_group_page)
|
|
||||||
{
|
|
||||||
// Show the "Edit Group" page
|
|
||||||
case 'edit':
|
|
||||||
include('pages/testimonial_groups_edit.php');
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Show the "Add New Group" page
|
|
||||||
case 'add_new':
|
|
||||||
include('pages/testimonial_groups_add_new.php');
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Default page, table with all available testimonial groups shown
|
|
||||||
default:
|
|
||||||
include('pages/testimonial_groups_index.php');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register admin stylesheet
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_tes_admin_init()
|
|
||||||
{
|
|
||||||
// Register stylesheet
|
|
||||||
wp_register_style('ltw_tes_stylesheet', WP_PLUGIN_URL.'/'.LTW_TES_FOLDER_NAME.'/css/style_admin.css');
|
|
||||||
}
|
|
||||||
add_action('admin_init', 'ltw_tes_admin_init');
|
|
||||||
|
|
||||||
function ltw_tes_admin_style()
|
|
||||||
{
|
|
||||||
wp_enqueue_style('ltw_tes_stylesheet');
|
|
||||||
|
|
||||||
wp_enqueue_script('media-upload');
|
|
||||||
wp_enqueue_script('thickbox');
|
|
||||||
wp_register_script('testimonials', WP_PLUGIN_URL.'/'.LTW_TES_FOLDER_NAME.'/js/testimonials.js', array('jquery','media-upload','thickbox'));
|
|
||||||
wp_enqueue_script('testimonials');
|
|
||||||
wp_enqueue_style('thickbox');
|
|
||||||
|
|
||||||
// embed the javascript file that makes the AJAX request
|
|
||||||
wp_enqueue_script('ltw_tes_ajax', WP_PLUGIN_URL.'/'.LTW_TES_FOLDER_NAME.'/js/ajax.js', array('jquery'), LTW_TES_VERSION);
|
|
||||||
wp_localize_script('ltw_tes_ajax', 'ltw_tes_ajax', array(
|
|
||||||
'ajaxurl' => admin_url('admin-ajax.php'),
|
|
||||||
'nonce' => wp_create_nonce('ltw_tes_ajax_nonce')
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When the plugin is deactivated, delete the junk.
|
|
||||||
* The junk being the tables that we created and any other extra records in "options" table. :)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_tes_plugin_uninstall()
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
if (get_option('ltw_tes_delete_tables') == '1')
|
|
||||||
{
|
|
||||||
// Delete groups table
|
|
||||||
$sql = "DROP TABLE IF EXISTS `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`";
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
// Delete testimonials table
|
|
||||||
$sql = "DROP TABLE IF EXISTS `".LTW_TES_TESTIMONIALS_TABLE."`";
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
// Finally, delete the extra records from "options" table
|
|
||||||
delete_option('ltw_tes_version');
|
|
||||||
delete_option('ltw_tes_sort_testimonials');
|
|
||||||
delete_option('ltw_tes_delete_tables');
|
|
||||||
delete_option('ltw_tes_design_css');
|
|
||||||
delete_option('ltw_tes_design_html');
|
|
||||||
delete_option('ltw_tes_promote_plugin');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
register_deactivation_hook(__FILE__, 'ltw_tes_plugin_uninstall');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Settings page
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_tes_settings()
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
include('pages/testimonial_settings.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shortcode stuff :)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_tes_shortcode($atts)
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
// Check if any attribute is set
|
|
||||||
$ltw_tes_group_id = isset($atts['group']) ? $atts['group'] : 0;
|
|
||||||
|
|
||||||
if ($ltw_tes_group_id == 0)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get order for testimonials
|
|
||||||
$ltw_testimonials_order_sql = '';
|
|
||||||
if (get_option('ltw_tes_sort_testimonials') == '1')
|
|
||||||
{
|
|
||||||
$ltw_testimonials_order_sql = ' ORDER BY `id` DESC ';
|
|
||||||
}
|
|
||||||
else if (get_option('ltw_tes_sort_testimonials') == '2')
|
|
||||||
{
|
|
||||||
$ltw_testimonials_order_sql = ' ORDER BY `id` ASC ';
|
|
||||||
}
|
|
||||||
else if (get_option('ltw_tes_sort_testimonials') == '3')
|
|
||||||
{
|
|
||||||
$ltw_testimonials_order_sql = ' ORDER BY `order` DESC ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare("
|
|
||||||
SELECT *
|
|
||||||
FROM ".LTW_TES_TESTIMONIALS_TABLE."
|
|
||||||
WHERE `group_id` = %d
|
|
||||||
".$ltw_testimonials_order_sql,
|
|
||||||
array($ltw_tes_group_id)
|
|
||||||
);
|
|
||||||
$ltw_tes_info = array();
|
|
||||||
$ltw_tes_info = $wpdb->get_results($sql, ARRAY_A);
|
|
||||||
|
|
||||||
if (count($ltw_tes_info) == 0)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = '';
|
|
||||||
|
|
||||||
// Add CSS style
|
|
||||||
$ltw_testimonial_str = '';
|
|
||||||
if (get_option('ltw_tes_design_css') != '')
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = '<style type="text/css">'.get_option('ltw_tes_design_css').'</style>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display the testimonials
|
|
||||||
foreach ($ltw_tes_info as $testimonial)
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str .= get_option('ltw_tes_design_html');
|
|
||||||
|
|
||||||
if ($testimonial['client_pic'] == '')
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%image%', get_bloginfo('url').'/wp-content/plugins/'.LTW_TES_FOLDER_NAME.'/images/blank.png', $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%image%', $testimonial['client_pic'], $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
$ltw_testimonial_str = str_replace('%testimonial%', '<a name="ltw_testimonial_'.$testimonial['id'].'"></a>%testimonial%', $ltw_testimonial_str);
|
|
||||||
$ltw_testimonial_str = str_replace('%testimonial%', stripslashes(nl2br($testimonial['testimonial'])), $ltw_testimonial_str);
|
|
||||||
$ltw_testimonial_str = str_replace('%client_name%', stripslashes($testimonial['client_name']), $ltw_testimonial_str);
|
|
||||||
|
|
||||||
if (strlen($testimonial['client_company']) > 0 && strlen($testimonial['client_website']) == 0)
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%client_company%', stripslashes($testimonial['client_company']), $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
else if (strlen($testimonial['client_company']) > 0 && strlen($testimonial['client_website']) > 0)
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%client_company%', '<a class="cite-link" href="'.$testimonial['client_website'].'">'.stripslashes($testimonial['client_company']).'</a>', $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
else if (strlen($testimonial['client_company']) == 0 && strlen($testimonial['client_website']) > 0)
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%client_company%', '<a class="cite-link" href="'.$testimonial['client_website'].'">'.$testimonial['client_website'].'</a>', $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%client_company%', '', $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (get_option('ltw_tes_promote_plugin') == '1')
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str .= '<div style="text-align: center;"><a href="http://www.lessthanweb.com/products/wp-plugin-ltw-testimonials">Powered by LTW Testimonials</a></div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $ltw_testimonial_str;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_shortcode('testimonial', 'ltw_tes_shortcode');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of client testimonials for the widget
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_tes_client_testimonials_widget($num, $group_id = '')
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
if ($group_id == '')
|
|
||||||
{
|
|
||||||
// First let's get a random group
|
|
||||||
$sql = $wpdb->prepare("
|
|
||||||
SELECT ltwg.*, ifnull(ltwt.`counter`, 0) AS `counter`
|
|
||||||
FROM `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."` AS ltwg
|
|
||||||
LEFT JOIN (
|
|
||||||
SELECT `group_id`, COUNT(*) AS `counter` FROM `".LTW_TES_TESTIMONIALS_TABLE."`
|
|
||||||
WHERE `show_in_widget` = 1
|
|
||||||
GROUP BY `group_id`
|
|
||||||
) AS ltwt
|
|
||||||
ON
|
|
||||||
ltwg.`id` = ltwt.`group_id`
|
|
||||||
"
|
|
||||||
);
|
|
||||||
$ltw_tes_group_info = array();
|
|
||||||
$ltw_tes_group_info = $wpdb->get_results($sql, ARRAY_A);
|
|
||||||
|
|
||||||
$ltw_tes_rand_group = array();
|
|
||||||
|
|
||||||
// Remove groups with 0 testimonials
|
|
||||||
foreach ($ltw_tes_group_info as $group)
|
|
||||||
{
|
|
||||||
if ($group['counter'] != 0)
|
|
||||||
{
|
|
||||||
$ltw_tes_rand_group[] = $group['id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$ltw_tes_rand_group_arr = mt_rand(0, (count($ltw_tes_rand_group)-1));
|
|
||||||
|
|
||||||
$ltw_show_group_id = $ltw_tes_rand_group[$ltw_tes_rand_group_arr];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ltw_show_group_id = $group_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare("
|
|
||||||
SELECT t.*, g.`group_name`, g.`page_id`
|
|
||||||
FROM ".LTW_TES_TESTIMONIALS_TABLE." AS t
|
|
||||||
LEFT JOIN ".LTW_TES_TESTIMONIAL_GROUPS_TABLE." AS g ON (g.`id` = t.`group_id`)
|
|
||||||
WHERE t.`group_id` = %d
|
|
||||||
AND t.`show_in_widget` = 1
|
|
||||||
ORDER BY RAND()
|
|
||||||
LIMIT ".$num."
|
|
||||||
", $ltw_show_group_id
|
|
||||||
);
|
|
||||||
$ltw_tes_info = array();
|
|
||||||
$ltw_tes_info = $wpdb->get_results($sql, ARRAY_A);
|
|
||||||
|
|
||||||
return $ltw_tes_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LTW Widget class
|
|
||||||
*/
|
|
||||||
if (version_compare($wp_version, '2.8', '>='))
|
|
||||||
{
|
|
||||||
class ltw_tes_widget extends WP_Widget
|
|
||||||
{
|
|
||||||
function ltw_tes_widget()
|
|
||||||
{
|
|
||||||
$widget_ops = array('classname' => 'widget_ltw_testimonials', 'description' => __('Display one or more client testimonials', LTW_TES_UNIQUE_NAME));
|
|
||||||
parent::WP_Widget('ltw_testimonials', __('Testimonials', LTW_TES_UNIQUE_NAME), $widget_ops);
|
|
||||||
}
|
|
||||||
|
|
||||||
function widget($args, $instance)
|
|
||||||
{
|
|
||||||
extract($args);
|
|
||||||
$ltw_title = apply_filters('widget_title', $instance['ltw_title']);
|
|
||||||
|
|
||||||
echo $before_widget;
|
|
||||||
|
|
||||||
if ($ltw_title)
|
|
||||||
echo $before_title . $ltw_title . $after_title;
|
|
||||||
|
|
||||||
$ltw_tes_info = ltw_tes_client_testimonials_widget($instance['ltw_number_of_testimonials'], $instance['ltw_one_group_only']);
|
|
||||||
|
|
||||||
if (count($ltw_tes_info) > 0)
|
|
||||||
{
|
|
||||||
foreach ($ltw_tes_info as $testimonial)
|
|
||||||
{
|
|
||||||
$ltw_testimonial_split = array();
|
|
||||||
|
|
||||||
// Check if user set the word limiter
|
|
||||||
if (isset($instance['ltw_set_word_limit']) == TRUE && $instance['ltw_set_word_limit'] != '0' && $instance['ltw_set_word_limit'] != '')
|
|
||||||
{
|
|
||||||
$ltw_testimonial_split = explode(' ', trim($testimonial['testimonial']));
|
|
||||||
|
|
||||||
if (is_numeric($instance['ltw_set_word_limit']))
|
|
||||||
{
|
|
||||||
$ltw_testimonial_tmp = '';
|
|
||||||
for ($i = 0; $i < $instance['ltw_set_word_limit']; $i++)
|
|
||||||
{
|
|
||||||
$ltw_testimonial_tmp .= $ltw_testimonial_split[$i].' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($ltw_testimonial_split) > $instance['ltw_set_word_limit'])
|
|
||||||
{
|
|
||||||
$ltw_testimonial_tmp = trim($ltw_testimonial_tmp).'...';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($ltw_testimonial_tmp) == TRUE && strlen($ltw_testimonial_tmp) > 0)
|
|
||||||
{
|
|
||||||
$testimonial['testimonial'] = $ltw_testimonial_tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($instance['ltw_show_picture']) == TRUE && $instance['ltw_show_picture'] == '1' && $testimonial['client_pic'] != '')
|
|
||||||
{
|
|
||||||
echo '<p><img src="'.stripslashes($testimonial['client_pic']).'" alt="'.stripslashes($testimonial['client_name']).'"/></p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<p>'.stripslashes(nl2br($testimonial['testimonial'])).'</p>';
|
|
||||||
echo '<p><cite>';
|
|
||||||
$ltw_client_info = stripslashes($testimonial['client_name']).'<br />';
|
|
||||||
|
|
||||||
if (strlen($testimonial['client_company']) > 0 && strlen($testimonial['client_website']) == 0)
|
|
||||||
{
|
|
||||||
$ltw_client_info .= stripslashes($testimonial['client_company']);
|
|
||||||
}
|
|
||||||
else if (strlen($testimonial['client_company']) > 0 && strlen($testimonial['client_website']) > 0)
|
|
||||||
{
|
|
||||||
$ltw_client_info .= '<a class="cite-link" href="'.$testimonial['client_website'].'">'.stripslashes($testimonial['client_company']).'</a>';
|
|
||||||
}
|
|
||||||
else if (strlen($testimonial['client_company']) == 0 && strlen($testimonial['client_website']) > 0)
|
|
||||||
{
|
|
||||||
$ltw_client_info .= '<a class="cite-link" href="'.$testimonial['client_website'].'">'.$testimonial['client_website'].'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo $ltw_client_info;
|
|
||||||
|
|
||||||
echo '</cite></p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($instance['ltw_show_more_link'] == '1')
|
|
||||||
{
|
|
||||||
$ltw_tes_page_data = get_page($testimonial['page_id']);
|
|
||||||
|
|
||||||
if (get_option('permalink_structure') == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_full_testimonials_url = get_bloginfo('url').'/?p='.$ltw_tes_page_data->ID;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ltw_tes_full_testimonials_url = get_bloginfo('url').'/'.$ltw_tes_page_data->post_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<p><a href="'.$ltw_tes_full_testimonials_url.'#ltw_testimonial_'.$testimonial['id'].'">'.$instance['ltw_show_more_text'].'</a></p>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo '<p>'.__('There are no testimonial yet', LTW_TES_UNIQUE_NAME).'</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo $after_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
function update($new_instance, $old_instance)
|
|
||||||
{
|
|
||||||
$instance = $old_instance;
|
|
||||||
$instance['ltw_title'] = strip_tags($new_instance['ltw_title']);
|
|
||||||
$instance['ltw_number_of_testimonials'] = strip_tags($new_instance['ltw_number_of_testimonials']);
|
|
||||||
$instance['ltw_show_more_link'] = strip_tags($new_instance['ltw_show_more_link']);
|
|
||||||
$instance['ltw_show_more_text'] = strip_tags($new_instance['ltw_show_more_text']);
|
|
||||||
$instance['ltw_set_word_limit'] = $new_instance['ltw_set_word_limit'];
|
|
||||||
$instance['ltw_one_group_only'] = $new_instance['ltw_one_group_only'];
|
|
||||||
$instance['ltw_show_picture'] = $new_instance['ltw_show_picture'];
|
|
||||||
|
|
||||||
return $instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
function form($instance)
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
$instance = wp_parse_args((array) $instance, array('ltw_title' => __('Testimonials', LTW_TES_UNIQUE_NAME)));
|
|
||||||
$ltw_title = esc_attr($instance['ltw_title']);
|
|
||||||
$ltw_number_of_testimonials = esc_attr($instance['ltw_number_of_testimonials']);
|
|
||||||
$ltw_show_more_link = esc_attr($instance['ltw_show_more_link']);
|
|
||||||
$ltw_show_more_text = esc_attr($instance['ltw_show_more_text']);
|
|
||||||
$ltw_set_word_limit = esc_attr($instance['ltw_set_word_limit']);
|
|
||||||
$ltw_one_group_only = esc_attr($instance['ltw_one_group_only']);
|
|
||||||
$ltw_show_picture = esc_attr($instance['ltw_show_picture']);
|
|
||||||
|
|
||||||
$sql = "SELECT `id`, `group_name`, `page_id`
|
|
||||||
FROM `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
ORDER BY `group_name` ASC";
|
|
||||||
$ltw_tes_group_info = array();
|
|
||||||
$ltw_tes_group_info = $wpdb->get_results($sql, ARRAY_A);
|
|
||||||
?>
|
|
||||||
<p><label for="<?php echo $this->get_field_id('ltw_title'); ?>"><?php _e('Title:', LTW_TES_UNIQUE_NAME); ?> <input class="widefat" id="<?php echo $this->get_field_id('ltw_title'); ?>" name="<?php echo $this->get_field_name('ltw_title'); ?>" type="text" value="<?php echo $ltw_title; ?>" /></label></p>
|
|
||||||
<p><label for="<?php echo $this->get_field_id('ltw_number_of_testimonials'); ?>"><?php _e('Show', LTW_TES_UNIQUE_NAME); ?> <input size="3" id="<?php echo $this->get_field_id('ltw_number_of_testimonials'); ?>" name="<?php echo $this->get_field_name('ltw_number_of_testimonials'); ?>" type="text" value="<?php echo $ltw_number_of_testimonials == '' ? '1' : $ltw_number_of_testimonials; ?>" /> <?php _e('testimonial(s)', LTW_TES_UNIQUE_NAME); ?></label></p>
|
|
||||||
<p><label for="<?php echo $this->get_field_id('ltw_show_more_link'); ?>"><input id="<?php echo $this->get_field_id('ltw_show_more_link'); ?>" name="<?php echo $this->get_field_name('ltw_show_more_link'); ?>" type="checkbox" value="1" <?php echo $ltw_show_more_link == '1' ? ' checked="checked"' : ''; ?>/> <?php _e('Display "Show More" link:', LTW_TES_UNIQUE_NAME); ?></label></p>
|
|
||||||
<p><label for="<?php echo $this->get_field_id('ltw_show_more_text'); ?>"><?php _e('"Show More" text:', LTW_TES_UNIQUE_NAME); ?> <input class="widefat" id="<?php echo $this->get_field_id('ltw_show_more_text'); ?>" name="<?php echo $this->get_field_name('ltw_show_more_text'); ?>" type="text" value="<?php echo $ltw_show_more_text; ?>" /></label></p>
|
|
||||||
<p><label for="<?php echo $this->get_field_id('ltw_set_word_limit'); ?>"><?php _e('Set word limit:', LTW_TES_UNIQUE_NAME); ?> <input size="3" id="<?php echo $this->get_field_id('ltw_set_word_limit'); ?>" name="<?php echo $this->get_field_name('ltw_set_word_limit'); ?>" type="text" value="<?php echo $ltw_set_word_limit == '' ? '0' : $ltw_set_word_limit; ?>" /></label></p>
|
|
||||||
<p><label for="<?php echo $this->get_field_id('ltw_one_group_only'); ?>"><?php _e('Show only this group:', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
<select name="<?php echo $this->get_field_name('ltw_one_group_only'); ?>" id="<?php echo $this->get_field_id('ltw_one_group_only'); ?>">
|
|
||||||
<option></option>
|
|
||||||
<?php
|
|
||||||
if (count($ltw_tes_group_info) > 0)
|
|
||||||
{
|
|
||||||
foreach ($ltw_tes_group_info as $group)
|
|
||||||
{
|
|
||||||
$ltw_group_selected = '';
|
|
||||||
if ($group['id'] == $ltw_one_group_only)
|
|
||||||
{
|
|
||||||
$ltw_group_selected = ' selected="selected"';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<option value="<?php echo $group['id']; ?>"<?php echo $ltw_group_selected; ?>><?php echo $group['group_name']; ?></option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</label></p>
|
|
||||||
<p><label for="<?php echo $this->get_field_id('ltw_show_picture'); ?>"><input id="<?php echo $this->get_field_id('ltw_show_picture'); ?>" name="<?php echo $this->get_field_name('ltw_show_picture'); ?>" type="checkbox" value="1" <?php echo $ltw_show_picture == '1' ? ' checked="checked"' : ''; ?>/> <?php _e('Check to display client picture', LTW_TES_UNIQUE_NAME); ?></label></p>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
add_action('widgets_init', create_function('', 'return register_widget("ltw_tes_widget");'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Design page for CSS and HTML of the testimonial
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_manage_testimonial_design()
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
include('pages/testimonial_design.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shortcode for displaying ALL the testimonials no matter which group they are in
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_tes_shortcode_all()
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
// Get order for testimonials
|
|
||||||
$ltw_testimonials_order_sql = '';
|
|
||||||
if (get_option('ltw_tes_sort_testimonials') == '1')
|
|
||||||
{
|
|
||||||
$ltw_testimonials_order_sql = ' ORDER BY `id` DESC ';
|
|
||||||
}
|
|
||||||
else if (get_option('ltw_tes_sort_testimonials') == '2')
|
|
||||||
{
|
|
||||||
$ltw_testimonials_order_sql = ' ORDER BY `id` ASC ';
|
|
||||||
}
|
|
||||||
else if (get_option('ltw_tes_sort_testimonials') == '3')
|
|
||||||
{
|
|
||||||
$ltw_testimonials_order_sql = ' ORDER BY `order` ASC ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare("
|
|
||||||
SELECT *
|
|
||||||
FROM ".LTW_TES_TESTIMONIALS_TABLE."
|
|
||||||
".$ltw_testimonials_order_sql,
|
|
||||||
array($ltw_tes_group_id)
|
|
||||||
);
|
|
||||||
$ltw_tes_info = array();
|
|
||||||
$ltw_tes_info = $wpdb->get_results($sql, ARRAY_A);
|
|
||||||
|
|
||||||
if (count($ltw_tes_info) == 0)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = '';
|
|
||||||
|
|
||||||
// Add CSS style
|
|
||||||
$ltw_testimonial_str = '<style type="text/css">'.get_option('ltw_tes_design_css').'</style>';
|
|
||||||
|
|
||||||
// Display the testimonials
|
|
||||||
foreach ($ltw_tes_info as $testimonial)
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str .= get_option('ltw_tes_design_html');
|
|
||||||
|
|
||||||
if ($testimonial['client_pic'] == '')
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%image%', get_bloginfo('url').'/wp-content/plugins/'.LTW_TES_FOLDER_NAME.'/images/blank.png', $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%image%', $testimonial['client_pic'], $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
$ltw_testimonial_str = str_replace('%testimonial%', '<a name="ltw_testimonial_'.$testimonial['id'].'"></a>%testimonial%', $ltw_testimonial_str);
|
|
||||||
$ltw_testimonial_str = str_replace('%testimonial%', stripslashes(nl2br($testimonial['testimonial'])), $ltw_testimonial_str);
|
|
||||||
$ltw_testimonial_str = str_replace('%client_name%', stripslashes($testimonial['client_name']), $ltw_testimonial_str);
|
|
||||||
|
|
||||||
if (strlen($testimonial['client_company']) > 0 && strlen($testimonial['client_website']) == 0)
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%client_company%', stripslashes($testimonial['client_company']), $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
else if (strlen($testimonial['client_company']) > 0 && strlen($testimonial['client_website']) > 0)
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%client_company%', '<a class="cite-link" href="'.$testimonial['client_website'].'">'.stripslashes($testimonial['client_company']).'</a>', $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
else if (strlen($testimonial['client_company']) == 0 && strlen($testimonial['client_website']) > 0)
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%client_company%', '<a class="cite-link" href="'.$testimonial['client_website'].'">'.$testimonial['client_website'].'</a>', $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str = str_replace('%client_company%', '', $ltw_testimonial_str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (get_option('ltw_tes_promote_plugin') == '1')
|
|
||||||
{
|
|
||||||
$ltw_testimonial_str .= '<div style="text-align: center;"><a href="http://www.lessthanweb.com/products/wp-plugin-ltw-testimonials">Powered by LTW Testimonials</a></div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $ltw_testimonial_str;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_shortcode('show_all_testimonials', 'ltw_tes_shortcode_all');
|
|
||||||
?>
|
|
||||||
@ -1,79 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Update for "Show in Widget"
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_tes_widget_visible()
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
$pops_nonce = $_POST['nonce'];
|
|
||||||
|
|
||||||
// Check to see if the nonce matches
|
|
||||||
if (wp_verify_nonce($pops_nonce, 'ltw_tes_ajax_nonce') == FALSE)
|
|
||||||
die(__('Oops, you are not allowed to do that!', LTW_TES_UNIQUE_NAME));
|
|
||||||
|
|
||||||
// Get the ID of the testimonial
|
|
||||||
$ltw_tes_id = isset($_POST['id']) == TRUE ? intval($_POST['id']) : 0;
|
|
||||||
|
|
||||||
// ID should never be 0!
|
|
||||||
if ($ltw_tes_id != 0)
|
|
||||||
{
|
|
||||||
// Is checkbox checked or not? :)
|
|
||||||
$ltw_tes_checked = isset($_POST['checked']) == TRUE && $_POST['checked'] == 'true' ? '1' : '0';
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare("
|
|
||||||
UPDATE `".LTW_TES_TESTIMONIALS_TABLE."`
|
|
||||||
SET `show_in_widget` = %d
|
|
||||||
WHERE `id` = %d
|
|
||||||
LIMIT 1",
|
|
||||||
array($ltw_tes_checked, $ltw_tes_id)
|
|
||||||
);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
echo $ltw_tes_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
add_action('wp_ajax_ltw_tes_widget_visible', 'ltw_tes_widget_visible');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update client testimonial order
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function ltw_tes_update_order()
|
|
||||||
{
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
$pops_nonce = $_POST['nonce'];
|
|
||||||
|
|
||||||
// Check to see if the nonce matches
|
|
||||||
if (wp_verify_nonce($pops_nonce, 'ltw_tes_ajax_nonce') == FALSE)
|
|
||||||
die(__('Oops, you are not allowed to do that!', LTW_TES_UNIQUE_NAME));
|
|
||||||
|
|
||||||
// Get the ID of the testimonial
|
|
||||||
$ltw_tes_id = isset($_POST['id']) == TRUE ? intval($_POST['id']) : 0;
|
|
||||||
|
|
||||||
// ID should never be 0!
|
|
||||||
if ($ltw_tes_id != 0)
|
|
||||||
{
|
|
||||||
// Get the order
|
|
||||||
$ltw_tes_order = isset($_POST['order']) == TRUE ? intval($_POST['order']) : '0';
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare("
|
|
||||||
UPDATE `".LTW_TES_TESTIMONIALS_TABLE."`
|
|
||||||
SET `order` = %d
|
|
||||||
WHERE `id` = %d
|
|
||||||
LIMIT 1",
|
|
||||||
array($ltw_tes_order, $ltw_tes_id)
|
|
||||||
);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
echo $ltw_tes_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
add_action('wp_ajax_ltw_tes_update_order', 'ltw_tes_update_order');
|
|
||||||
?>
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
<a href="http://www.lessthanweb.com/products/wp-plugin-ltw-testimonials" target="_blank">Support</a> |
|
|
||||||
<a href="http://www.lessthanweb.com/products/wp-plugin-ltw-testimonials" target="_blank">Make a donation</a>
|
|
||||||
@ -1,247 +0,0 @@
|
|||||||
<?php
|
|
||||||
$ltw_tes_errors = array();
|
|
||||||
$ltw_tes_success = "";
|
|
||||||
$ltw_tes_error_found = FALSE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all available groups
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$sql = "SELECT `id`, `group_name`, `page_id`
|
|
||||||
FROM `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
ORDER BY `group_name` ASC";
|
|
||||||
$ltw_tes_group_info = array();
|
|
||||||
$ltw_tes_group_info = $wpdb->get_results($sql, ARRAY_A);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Preset the form fields
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$form = array(
|
|
||||||
'ltw_tes_client_testimonial' => '',
|
|
||||||
'ltw_tes_group_id' => '',
|
|
||||||
'ltw_tes_new_group_name' => '',
|
|
||||||
'ltw_tes_client_name' => '',
|
|
||||||
'ltw_tes_client_website' => '',
|
|
||||||
'ltw_tes_client_company' => '',
|
|
||||||
'ltw_tes_show_widget' => '0',
|
|
||||||
'upload_image' => '',
|
|
||||||
'ltw_tes_order' => '0'
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form submitted, check the data
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if (isset($_POST['form_submit']) && $_POST['form_submit'] == 'yes')
|
|
||||||
{
|
|
||||||
// Just a little ;) security thingy that wordpress offers us
|
|
||||||
check_admin_referer('ltw_tes_add_new_testimonial_form');
|
|
||||||
|
|
||||||
$form['ltw_tes_group_id'] = isset($_POST['ltw_tes_group_id']) ? $_POST['ltw_tes_group_id'] : '';
|
|
||||||
$form['ltw_tes_new_group_name'] = isset($_POST['ltw_tes_new_group_name']) ? $_POST['ltw_tes_new_group_name'] : '';
|
|
||||||
if ($form['ltw_tes_group_id'] == '' && $form['ltw_tes_new_group_name'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Please select a group or create a new one.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if group already exist. This is when user wants to create new group!
|
|
||||||
if ($form['ltw_tes_group_id'] == '' && $form['ltw_tes_new_group_name'] != '')
|
|
||||||
{
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"SELECT COUNT(*) AS `count` FROM ".LTW_TES_TESTIMONIAL_GROUPS_TABLE."
|
|
||||||
WHERE `group_name` = %s",
|
|
||||||
array($form['ltw_tes_new_group_name'])
|
|
||||||
);
|
|
||||||
$result = '0';
|
|
||||||
$result = $wpdb->get_var($sql);
|
|
||||||
|
|
||||||
if ($result != '0')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Group with the same name already exist.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$form['ltw_tes_show_widget'] = isset($_POST['ltw_tes_show_widget']) ? '1' : '0';
|
|
||||||
|
|
||||||
$form['ltw_tes_client_name'] = isset($_POST['ltw_tes_client_name']) ? $_POST['ltw_tes_client_name'] : '';
|
|
||||||
if ($form['ltw_tes_client_name'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Please enter the name of the client.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$form['upload_image'] = isset($_POST['upload_image']) ? $_POST['upload_image'] : '';
|
|
||||||
if ($form['upload_image'] == 'http://')
|
|
||||||
{
|
|
||||||
$form['upload_image'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$form['ltw_tes_client_company'] = isset($_POST['ltw_tes_client_company']) ? $_POST['ltw_tes_client_company'] : '';
|
|
||||||
|
|
||||||
$form['ltw_tes_client_website'] = isset($_POST['ltw_tes_client_website']) ? $_POST['ltw_tes_client_website'] : '';
|
|
||||||
|
|
||||||
$form['ltw_tes_client_testimonial'] = isset($_POST['ltw_tes_client_testimonial']) ? $_POST['ltw_tes_client_testimonial'] : '';
|
|
||||||
if ($form['ltw_tes_client_testimonial'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Please enter the clients testimonial', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$form['ltw_tes_order'] = isset($_POST['ltw_tes_order']) ? $_POST['ltw_tes_order'] : '';
|
|
||||||
if ($form['ltw_tes_order'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Please enter the order.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No errors found, we can add this Group to the table
|
|
||||||
if ($ltw_tes_error_found == FALSE)
|
|
||||||
{
|
|
||||||
// If user wants to create a new group, let's do so then :)
|
|
||||||
if ($form['ltw_tes_group_id'] == '' && $form['ltw_tes_new_group_name'] != '')
|
|
||||||
{
|
|
||||||
// Create new group
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"INSERT INTO `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
(`group_name`)
|
|
||||||
VALUES(%s)",
|
|
||||||
array($form['ltw_tes_new_group_name'])
|
|
||||||
);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
$form['ltw_tes_group_id'] = $wpdb->insert_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"INSERT INTO `".LTW_TES_TESTIMONIALS_TABLE."`
|
|
||||||
(`group_id`, `testimonial`, `client_name`, `client_pic`, `client_website`, `client_company`, `show_in_widget`, `order`)
|
|
||||||
VALUES(%d, %s, %s, %s, %s, %s, %d, %s)",
|
|
||||||
array($form['ltw_tes_group_id'], $form['ltw_tes_client_testimonial'], $form['ltw_tes_client_name'], $form['upload_image'], $form['ltw_tes_client_website'], $form['ltw_tes_client_company'], $form['ltw_tes_show_widget'], $form['ltw_tes_order'])
|
|
||||||
);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
// Also update the testimonial counter for group
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"UPDATE `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
SET `count` = `count` + 1
|
|
||||||
WHERE id = %d",
|
|
||||||
array($form['ltw_tes_group_id'])
|
|
||||||
);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
$ltw_tes_success = __('Client testimonial was successfully added.', LTW_TES_UNIQUE_NAME);
|
|
||||||
|
|
||||||
// Clear the fields
|
|
||||||
$form = array(
|
|
||||||
'ltw_tes_client_testimonial' => '',
|
|
||||||
'ltw_tes_group_id' => '',
|
|
||||||
'ltw_tes_new_group_name' => '',
|
|
||||||
'ltw_tes_client_name' => '',
|
|
||||||
'ltw_tes_client_website' => '',
|
|
||||||
'ltw_tes_client_company' => '',
|
|
||||||
'upload_image' => '',
|
|
||||||
'ltw_tes_show_widget' => '0',
|
|
||||||
'ltw_tes_order' => '0'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
<h2><?php _e('Add New Testimonial', LTW_TES_UNIQUE_NAME); ?></h2>
|
|
||||||
<div id="ltw_tes_quick_links">
|
|
||||||
<?php include('quick_links_right.php'); ?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
if ($ltw_tes_error_found == TRUE && isset($ltw_tes_errors[0]) == TRUE)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="error fade"><p><strong><?php echo $ltw_tes_errors[0]; ?></strong></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ltw_tes_error_found == FALSE && strlen($ltw_tes_success) > 0)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="updated fade"><p><strong><?php echo $ltw_tes_success; ?></strong></p><p><a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonials"><?php _e('Click here', LTW_TES_UNIQUE_NAME); ?></a> <?php _e('to go back to the testimonials overview page.', LTW_TES_UNIQUE_NAME); ?></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<form method="post" action="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonials&sp=add_new">
|
|
||||||
<div>
|
|
||||||
<input type="hidden" name="form_submit" value="yes"/>
|
|
||||||
<?php wp_nonce_field('ltw_tes_add_new_testimonial_form'); ?>
|
|
||||||
</div>
|
|
||||||
<table class="form-table">
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Select Group', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td>
|
|
||||||
<select name="ltw_tes_group_id">
|
|
||||||
<option></option>
|
|
||||||
<?php
|
|
||||||
if (count($ltw_tes_group_info) > 0)
|
|
||||||
{
|
|
||||||
foreach ($ltw_tes_group_info as $group)
|
|
||||||
{
|
|
||||||
$ltw_group_selected = '';
|
|
||||||
if ($group['id'] == $form['ltw_tes_group_id'])
|
|
||||||
{
|
|
||||||
$ltw_group_selected = ' selected="selected"';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<option value="<?php echo $group['id']; ?>"<?php echo $ltw_group_selected; ?>><?php echo $group['group_name']; ?></option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
<?php _e('or create new one', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
<input type="text" name="ltw_tes_new_group_name" class="regular-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_new_group_name'])); ?>" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Show in Widget', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><label for="ltw_tes_show_widget"><input type="checkbox" name="ltw_tes_show_widget" id="ltw_tes_show_widget" value="1"<?php echo isset($form['ltw_tes_show_widget']) && $form['ltw_tes_show_widget'] == '1' ? ' checked="checked"' : ''; ?> /> <?php _e('Show this client testimonial in the Widget', LTW_TES_UNIQUE_NAME); ?></label></td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Client Name', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><input type="text" name="ltw_tes_client_name" class="regular-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_client_name'])); ?>" /></td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Picture', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td>
|
|
||||||
<input id="upload_image" type="text" size="36" name="upload_image" value="" />
|
|
||||||
<input id="upload_image_button" type="button" value="<?php _e('Upload', LTW_TES_UNIQUE_NAME); ?>" />
|
|
||||||
<br />
|
|
||||||
<?php _e('Enter an URL or upload an image.', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
<br />
|
|
||||||
<?php _e('To change the image size, change the width and height in the <a href="'.get_option('siteurl').'/wp-admin/admin.php?page=ltw_manage_testimonial_design">CSS code</a> under the class "ltw_tes_image_cont".', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
<br />
|
|
||||||
<?php _e('Default size of the image is 88px x 88px.', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Company', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><input type="text" name="ltw_tes_client_company" class="regular-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_client_company'])); ?>" /> <span class="description"><?php _e('Optional', LTW_TES_UNIQUE_NAME); ?></span></td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Website', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><input type="text" name="ltw_tes_client_website" class="regular-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_client_website'])); ?>" /> <span class="description"><?php _e('Optional', LTW_TES_UNIQUE_NAME); ?></span></td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row" colspan="2">
|
|
||||||
<script type="text/javascript" src="<?php echo get_option('siteurl'); ?>/wp-content/plugins/ltw-testimonials/js/js_quicktags.js"></script>
|
|
||||||
<script type="text/javascript">edToolbar('ltw_tes_client_testimonial');</script>
|
|
||||||
<textarea class="large-text code" id="ltw_tes_client_testimonial" cols="50" rows="10" name="ltw_tes_client_testimonial"><?php echo esc_html(stripslashes($form['ltw_tes_client_testimonial'])); ?></textarea>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Order', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><input type="text" name="ltw_tes_order" class="small-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_order'])); ?>" /></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<p class="submit"><input type="submit" class="button-primary" value="<?php _e('Add Testimonial', LTW_TES_UNIQUE_NAME); ?>" /></p>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
<div class="wrap">
|
|
||||||
<h2><?php _e('Testimonial Design', LTW_TES_UNIQUE_NAME); ?></h2>
|
|
||||||
<div id="ltw_tes_quick_links">
|
|
||||||
<?php include('quick_links_right.php'); ?>
|
|
||||||
</div>
|
|
||||||
<div class="error fade"><p><strong><?php _e('Be aware that by changing the HTML and CSS incorrectly it may mess up your blog layout. Be careful!<br />If you are unsure about something, ask someone who knows.', LTW_TES_UNIQUE_NAME); ?></strong></p></div>
|
|
||||||
<?php
|
|
||||||
if ($_GET['updated'] == 'true')
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div id="message" class="updated fade"><p><strong><?php _e('Design Updated', LTW_TES_UNIQUE_NAME); ?></strong></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<form method="post" action="<?php echo get_option('siteurl'); ?>/wp-admin/options.php">
|
|
||||||
<div>
|
|
||||||
<?php settings_fields('ltw-testimonials-design'); ?>
|
|
||||||
</div>
|
|
||||||
<table class="form-table">
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('HTML Code', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td>
|
|
||||||
<textarea class="large-text" cols="20" rows="10" name="ltw_tes_design_html" id="ltw_tes_design_html"><?php echo get_option('ltw_tes_design_html'); ?></textarea>
|
|
||||||
<br />
|
|
||||||
<span class="description">
|
|
||||||
<?php _e('There are some template variables that you need to include in the HTML.', LTW_TES_UNIQUE_NAME); ?><br /><br />
|
|
||||||
%image% = <?php _e('It will display the URL to the image.', LTW_TES_UNIQUE_NAME); ?><br />
|
|
||||||
%testimonial% = <?php _e('Displays the testimonial text.', LTW_TES_UNIQUE_NAME); ?><br />
|
|
||||||
%client_name% = <?php _e('Displays the client name.', LTW_TES_UNIQUE_NAME); ?><br />
|
|
||||||
%client_company% = <?php _e('It will display either the company name, the url to the company name or company name as a link to their website. It depends on what you have entered for this two fields.', LTW_TES_UNIQUE_NAME); ?><br />
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('CSS Code', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><textarea class="large-text" cols="20" rows="10" name="ltw_tes_design_css" id="ltw_tes_design_css"><?php echo get_option('ltw_tes_design_css'); ?></textarea></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<p class="submit"><input type="submit" class="button-primary" value="<?php _e('Update', LTW_TES_UNIQUE_NAME); ?>" /></p>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
@ -1,275 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* First check if ID exist with requested ID
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$ltw_tes_id = isset($_GET['id']) ? $_GET['id'] : '0';
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"SELECT COUNT(*) AS `count` FROM ".LTW_TES_TESTIMONIALS_TABLE."
|
|
||||||
WHERE `id` = %d",
|
|
||||||
array($ltw_tes_id)
|
|
||||||
);
|
|
||||||
$result = '0';
|
|
||||||
$result = $wpdb->get_var($sql);
|
|
||||||
|
|
||||||
if ($result != '1')
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
<h2><?php _e('Edit Testimonial', LTW_TES_UNIQUE_NAME); ?></h2>
|
|
||||||
<div id="ltw_tes_quick_links">
|
|
||||||
<?php include('quick_links_right.php'); ?>
|
|
||||||
</div>
|
|
||||||
<div class="error fade"><p><strong><?php _e('Oops, selected testimonial doesn\'t exist.', LTW_TES_UNIQUE_NAME); ?></strong> <a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonials"><?php _e('Click here', LTW_TES_UNIQUE_NAME); ?></a> <?php _e('to go back to the overview page.', LTW_TES_UNIQUE_NAME); ?></p></div>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ltw_tes_errors = array();
|
|
||||||
$ltw_tes_success = "";
|
|
||||||
$ltw_tes_error_found = FALSE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all available groups
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$sql = "SELECT `id`, `group_name`, `page_id`
|
|
||||||
FROM `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
ORDER BY `group_name` ASC";
|
|
||||||
$ltw_tes_group_info = array();
|
|
||||||
$ltw_tes_group_info = $wpdb->get_results($sql, ARRAY_A);
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare("
|
|
||||||
SELECT *
|
|
||||||
FROM `".LTW_TES_TESTIMONIALS_TABLE."`
|
|
||||||
WHERE `id` = %d
|
|
||||||
LIMIT 1
|
|
||||||
",
|
|
||||||
array($ltw_tes_id)
|
|
||||||
);
|
|
||||||
$ltw_tes_info = array();
|
|
||||||
$ltw_tes_info = $wpdb->get_row($sql, ARRAY_A);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Preset the form fields
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$form = array(
|
|
||||||
'ltw_tes_client_testimonial' => $ltw_tes_info['testimonial'],
|
|
||||||
'ltw_tes_group_id' => $ltw_tes_info['group_id'],
|
|
||||||
'ltw_tes_new_group_name' => '',
|
|
||||||
'ltw_tes_client_name' => $ltw_tes_info['client_name'],
|
|
||||||
'ltw_tes_client_website' => $ltw_tes_info['client_website'],
|
|
||||||
'ltw_tes_client_company' => $ltw_tes_info['client_company'],
|
|
||||||
'ltw_tes_show_widget' => $ltw_tes_info['show_in_widget'],
|
|
||||||
'upload_image' => $ltw_tes_info['client_pic'],
|
|
||||||
'ltw_tes_order' => $ltw_tes_info['order']
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form submitted, check the data
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if (isset($_POST['form_submit']) && $_POST['form_submit'] == 'yes')
|
|
||||||
{
|
|
||||||
// Just a little ;) security thingy that wordpress offers us
|
|
||||||
check_admin_referer('ltw_tes_edit_testimonial_form');
|
|
||||||
|
|
||||||
$form['ltw_tes_group_id'] = isset($_POST['ltw_tes_group_id']) ? $_POST['ltw_tes_group_id'] : '';
|
|
||||||
$form['ltw_tes_new_group_name'] = isset($_POST['ltw_tes_new_group_name']) ? $_POST['ltw_tes_new_group_name'] : '';
|
|
||||||
if ($form['ltw_tes_group_id'] == '' && $form['ltw_tes_new_group_name'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Please select a group or create a new one.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if group already exist. This is when user wants to create new group!
|
|
||||||
if ($form['ltw_tes_group_id'] == '' && $form['ltw_tes_new_group_name'] != '')
|
|
||||||
{
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"SELECT COUNT(*) AS `count` FROM ".LTW_TES_TESTIMONIAL_GROUPS_TABLE."
|
|
||||||
WHERE `group_name` = %s",
|
|
||||||
array($form['ltw_tes_new_group_name'])
|
|
||||||
);
|
|
||||||
$result = '0';
|
|
||||||
$result = $wpdb->get_var($sql);
|
|
||||||
|
|
||||||
if ($result != '0')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Group with the same name already exist.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$form['ltw_tes_show_widget'] = isset($_POST['ltw_tes_show_widget']) ? '1' : '0';
|
|
||||||
|
|
||||||
$form['ltw_tes_client_name'] = isset($_POST['ltw_tes_client_name']) ? $_POST['ltw_tes_client_name'] : '';
|
|
||||||
if ($form['ltw_tes_client_name'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Please enter the name of the client.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$form['upload_image'] = isset($_POST['upload_image']) ? $_POST['upload_image'] : '';
|
|
||||||
if ($form['upload_image'] == 'http://')
|
|
||||||
{
|
|
||||||
$form['upload_image'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$form['ltw_tes_client_company'] = isset($_POST['ltw_tes_client_company']) ? $_POST['ltw_tes_client_company'] : '';
|
|
||||||
|
|
||||||
$form['ltw_tes_client_website'] = isset($_POST['ltw_tes_client_website']) ? $_POST['ltw_tes_client_website'] : '';
|
|
||||||
|
|
||||||
$form['ltw_tes_client_testimonial'] = isset($_POST['ltw_tes_client_testimonial']) ? $_POST['ltw_tes_client_testimonial'] : '';
|
|
||||||
if ($form['ltw_tes_client_testimonial'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Please enter the clients testimonial', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$form['ltw_tes_order'] = isset($_POST['ltw_tes_order']) ? $_POST['ltw_tes_order'] : '';
|
|
||||||
if ($form['ltw_tes_order'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Please enter the order.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No errors found, we can add this Group to the table
|
|
||||||
if ($ltw_tes_error_found == FALSE)
|
|
||||||
{
|
|
||||||
// If user wants to create a new group, let's do so then :)
|
|
||||||
if ($form['ltw_tes_group_id'] == '' && $form['ltw_tes_new_group_name'] != '')
|
|
||||||
{
|
|
||||||
// Create new group
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"INSERT INTO `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
(`group_name`)
|
|
||||||
VALUES(%s)",
|
|
||||||
array($form['ltw_tes_new_group_name'])
|
|
||||||
);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
$form['ltw_tes_group_id'] = $wpdb->insert_id();
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"UPDATE `".LTW_TES_TESTIMONIALS_TABLE."`
|
|
||||||
SET `group_id` = %d,
|
|
||||||
`testimonial` = %s,
|
|
||||||
`client_name` = %s,
|
|
||||||
`client_pic` = %s,
|
|
||||||
`client_website` = %s,
|
|
||||||
`client_company` = %s,
|
|
||||||
`show_in_widget` = %d,
|
|
||||||
`order` = %d
|
|
||||||
WHERE id = %d
|
|
||||||
LIMIT 1",
|
|
||||||
array($form['ltw_tes_group_id'], $form['ltw_tes_client_testimonial'], $form['ltw_tes_client_name'], $form['upload_image'], $form['ltw_tes_client_website'], $form['ltw_tes_client_company'], $form['ltw_tes_show_widget'], $form['ltw_tes_order'], $ltw_tes_id)
|
|
||||||
);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
$ltw_tes_success = __('Client testimonial was successfully updated.', LTW_TES_UNIQUE_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
<h2><?php _e('Add New Testimonial', LTW_TES_UNIQUE_NAME); ?></h2>
|
|
||||||
<div id="ltw_tes_quick_links">
|
|
||||||
<?php include('quick_links_right.php'); ?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
if ($ltw_tes_error_found == TRUE && isset($ltw_tes_errors[0]) == TRUE)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="error fade"><p><strong><?php echo $ltw_tes_errors[0]; ?></strong></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ltw_tes_error_found == FALSE && strlen($ltw_tes_success) > 0)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="updated fade"><p><strong><?php echo $ltw_tes_success; ?></strong></p><p><a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonials"><?php _e('Click here', LTW_TES_UNIQUE_NAME); ?></a> <?php _e('to go back to the testimonials overview page', LTW_TES_UNIQUE_NAME); ?> <?php _e('or', LTW_TES_UNIQUE_NAME); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonials&sp=add_new"><?php _e('click here', LTW_TES_UNIQUE_NAME); ?></a> <?php _e('to add another client testimonial.', LTW_TES_UNIQUE_NAME); ?></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<form method="post" action="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonials&sp=edit&id=<?php echo $ltw_tes_id; ?>">
|
|
||||||
<div>
|
|
||||||
<input type="hidden" name="form_submit" value="yes"/>
|
|
||||||
<?php wp_nonce_field('ltw_tes_edit_testimonial_form'); ?>
|
|
||||||
</div>
|
|
||||||
<table class="form-table">
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Select Group', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td>
|
|
||||||
<select name="ltw_tes_group_id">
|
|
||||||
<option></option>
|
|
||||||
<?php
|
|
||||||
if (count($ltw_tes_group_info) > 0)
|
|
||||||
{
|
|
||||||
foreach ($ltw_tes_group_info as $group)
|
|
||||||
{
|
|
||||||
$ltw_group_selected = '';
|
|
||||||
if ($group['id'] == $form['ltw_tes_group_id'])
|
|
||||||
{
|
|
||||||
$ltw_group_selected = ' selected="selected"';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<option value="<?php echo $group['id']; ?>"<?php echo $ltw_group_selected; ?>><?php echo $group['group_name']; ?></option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
<?php _e('or create new one', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
<input type="text" name="ltw_tes_new_group_name" class="regular-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_new_group_name'])); ?>" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Show in Widget', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><input type="checkbox" name="ltw_tes_show_widget" value="1"<?php echo isset($form['ltw_tes_show_widget']) && $form['ltw_tes_show_widget'] == '1' ? ' checked="checked"' : ''; ?> /> <?php _e('Show this client testimonial in the Widget', LTW_TES_UNIQUE_NAME); ?></td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Client Name', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><input type="text" name="ltw_tes_client_name" class="regular-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_client_name'])); ?>" /></td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Picture', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td>
|
|
||||||
<input id="upload_image" type="text" size="36" name="upload_image" value="<?php echo esc_html(stripslashes($form['upload_image'])); ?>" />
|
|
||||||
<input id="upload_image_button" type="button" value="<?php _e('Upload', LTW_TES_UNIQUE_NAME); ?>" />
|
|
||||||
<br />
|
|
||||||
<?php _e('Enter an URL or upload an image.', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
<br />
|
|
||||||
<?php _e('To change the image size, change the width and height in the <a href="'.get_option('siteurl').'/wp-admin/admin.php?page=ltw_manage_testimonial_design">CSS code</a> under the class "ltw_tes_image_cont".', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
<br />
|
|
||||||
<?php _e('Default size of the image is 88px x 88px.', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Company', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><input type="text" name="ltw_tes_client_company" class="regular-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_client_company'])); ?>" /> <span class="description"><?php _e('Optional', LTW_TES_UNIQUE_NAME); ?></span></td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Website', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><input type="text" name="ltw_tes_client_website" class="regular-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_client_website'])); ?>" /> <span class="description"><?php _e('Optional', LTW_TES_UNIQUE_NAME); ?></span></td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row" colspan="2">
|
|
||||||
<script type="text/javascript" src="<?php echo get_option('siteurl'); ?>/wp-content/plugins/ltw-testimonials/js/js_quicktags.js"></script>
|
|
||||||
<script type="text/javascript">edToolbar('ltw_tes_client_testimonial');</script>
|
|
||||||
<textarea class="large-text code" id="ltw_tes_client_testimonial" cols="50" rows="10" name="ltw_tes_client_testimonial"><?php echo esc_html(stripslashes($form['ltw_tes_client_testimonial'])); ?></textarea>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Order', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><input type="text" name="ltw_tes_order" class="small-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_order'])); ?>" /></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<p class="submit"><input type="submit" class="button-primary" value="<?php _e('Update Testimonial', LTW_TES_UNIQUE_NAME); ?>" /></p>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
@ -1,132 +0,0 @@
|
|||||||
<?php
|
|
||||||
$ltw_tes_errors = array();
|
|
||||||
$ltw_tes_success = '';
|
|
||||||
$ltw_tes_error_found = FALSE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Preset the form fields
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$form = array(
|
|
||||||
'ltw_tes_group_name' => '',
|
|
||||||
'ltw_tes_page' => ''
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form submitted, check the data
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if (isset($_POST['form_submit']) && $_POST['form_submit'] == 'yes')
|
|
||||||
{
|
|
||||||
// Just a little ;) security thingy that wordpress offers us
|
|
||||||
check_admin_referer('ltw_tes_add_new_group_form');
|
|
||||||
|
|
||||||
$form['ltw_tes_group_name'] = isset($_POST['ltw_tes_group_name']) ? $_POST['ltw_tes_group_name'] : '';
|
|
||||||
if ($form['ltw_tes_group_name'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Please enter the name of the group.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$form['ltw_tes_page'] = isset($_POST['ltw_tes_page']) ? $_POST['ltw_tes_page'] : '';
|
|
||||||
if ($form['ltw_tes_page'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Please select the page.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if group name already exist
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"SELECT COUNT(*) AS `count` FROM ".LTW_TES_TESTIMONIAL_GROUPS_TABLE."
|
|
||||||
WHERE `group_name` = %s",
|
|
||||||
array($form['ltw_tes_group_name'])
|
|
||||||
);
|
|
||||||
$result = '0';
|
|
||||||
$result = $wpdb->get_var($sql);
|
|
||||||
|
|
||||||
if ($result != '0')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Group with the same name already exist.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No errors found, we can add this Group to the table
|
|
||||||
if ($ltw_tes_error_found == FALSE)
|
|
||||||
{
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"INSERT INTO `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
(`group_name`, `page_id`)
|
|
||||||
VALUES(%s, %d)",
|
|
||||||
array($form['ltw_tes_group_name'], $form['ltw_tes_page'])
|
|
||||||
);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
$ltw_tes_success = __('Testimonial group was successfully added.', LTW_TES_UNIQUE_NAME);
|
|
||||||
|
|
||||||
// Reset form fields
|
|
||||||
$form = array(
|
|
||||||
'ltw_tes_group_name' => '',
|
|
||||||
'ltw_tes_page' => ''
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
<h2><?php _e('Add New Testimonial Group', LTW_TES_UNIQUE_NAME); ?></h2>
|
|
||||||
<div id="ltw_tes_quick_links">
|
|
||||||
<?php include('quick_links_right.php'); ?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
if ($ltw_tes_error_found == TRUE && isset($ltw_tes_errors[0]) == TRUE)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="error fade"><p><strong><?php echo $ltw_tes_errors[0]; ?></strong></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ltw_tes_error_found == FALSE && strlen($ltw_tes_success) > 0)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="updated fade"><p><strong><?php echo $ltw_tes_success; ?></strong></p><p><a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonial_groups"><?php _e('Click here', LTW_TES_UNIQUE_NAME); ?></a> <?php _e('to go back to groups overview page.', LTW_TES_UNIQUE_NAME); ?></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<form method="post" action="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonial_groups&sp=add_new">
|
|
||||||
<div>
|
|
||||||
<input type="hidden" name="form_submit" value="yes"/>
|
|
||||||
<?php wp_nonce_field('ltw_tes_add_new_group_form'); ?>
|
|
||||||
</div>
|
|
||||||
<table class="form-table">
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Group Name', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><input type="text" name="ltw_tes_group_name" class="regular-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_group_name'])); ?>" /></td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Testimonial Page', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td>
|
|
||||||
<select name="ltw_tes_page">
|
|
||||||
<option></option>
|
|
||||||
<?php
|
|
||||||
foreach (get_pages() as $key => $value)
|
|
||||||
{
|
|
||||||
$selected_page = '';
|
|
||||||
if ($form['ltw_tes_page'] == $value->ID)
|
|
||||||
{
|
|
||||||
$selected_page = ' selected="selected"';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<option value="<?php echo $value->ID; ?>"<?php echo $selected_page; ?>><?php echo $value->post_title; ?></option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
<br/>
|
|
||||||
<span class="description"><?php _e('This is the page where all the testimonials from this group will be shown. It is used for the "Show More" link in the widget.', LTW_TES_UNIQUE_NAME); ?></span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<p class="submit">
|
|
||||||
<input type="submit" class="button-primary" value="<?php _e('Add Group', LTW_TES_UNIQUE_NAME); ?>" />
|
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
@ -1,171 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* First check if ID exist with requested ID
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$ltw_tes_group_id = isset($_GET['id']) ? $_GET['id'] : '0';
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"SELECT COUNT(*) AS `count` FROM ".LTW_TES_TESTIMONIAL_GROUPS_TABLE."
|
|
||||||
WHERE `id` = %d",
|
|
||||||
array($ltw_tes_group_id)
|
|
||||||
);
|
|
||||||
$result = '0';
|
|
||||||
$result = $wpdb->get_var($sql);
|
|
||||||
|
|
||||||
if ($result != '1')
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
<h2><?php _e('Edit Testimonial Group', LTW_TES_UNIQUE_NAME); ?></h2>
|
|
||||||
<div id="ltw_tes_quick_links">
|
|
||||||
<?php include('quick_links_right.php'); ?>
|
|
||||||
</div>
|
|
||||||
<div class="error fade"><p><strong><?php _e('Selected testimonial group doesn\'t exist.', LTW_TES_UNIQUE_NAME); ?></strong> <a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonial_groups"><?php _e('Click here', LTW_TES_UNIQUE_NAME); ?></a> <?php _e('to go back to the group overview page.', LTW_TES_UNIQUE_NAME); ?></p></div>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ltw_tes_errors = array();
|
|
||||||
$ltw_tes_success = '';
|
|
||||||
$ltw_tes_error_found = FALSE;
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare("
|
|
||||||
SELECT `id`, `group_name`, `page_id`
|
|
||||||
FROM `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
WHERE `id` = %d
|
|
||||||
LIMIT 1
|
|
||||||
",
|
|
||||||
array($ltw_tes_group_id)
|
|
||||||
);
|
|
||||||
$ltw_tes_group_info = array();
|
|
||||||
$ltw_tes_group_info = $wpdb->get_row($sql, ARRAY_A);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Preset the form fields
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$form = array(
|
|
||||||
'ltw_tes_group_name' => $ltw_tes_group_info['group_name'],
|
|
||||||
'ltw_tes_page' => $ltw_tes_group_info['page_id']
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form submitted, check the data
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if (isset($_POST['form_submit']) && $_POST['form_submit'] == 'yes')
|
|
||||||
{
|
|
||||||
// Just a little ;) security thingy that wordpress offers us
|
|
||||||
check_admin_referer('ltw_tes_edit_group_form');
|
|
||||||
|
|
||||||
$form['ltw_tes_group_name'] = isset($_POST['ltw_tes_group_name']) ? $_POST['ltw_tes_group_name'] : '';
|
|
||||||
if ($form['ltw_tes_group_name'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Group Name field is required.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$form['ltw_tes_page'] = isset($_POST['ltw_tes_page']) ? $_POST['ltw_tes_page'] : '';
|
|
||||||
if ($form['ltw_tes_page'] == '')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Please select the page.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if group name already exist
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"SELECT COUNT(*) AS `count` FROM ".LTW_TES_TESTIMONIAL_GROUPS_TABLE."
|
|
||||||
WHERE `group_name` = %s
|
|
||||||
AND `id` <> %d",
|
|
||||||
array($form['ltw_tes_group_name'], $ltw_tes_group_id)
|
|
||||||
);
|
|
||||||
$result = '0';
|
|
||||||
$result = $wpdb->get_var($sql);
|
|
||||||
|
|
||||||
if ($result != '0')
|
|
||||||
{
|
|
||||||
$ltw_tes_errors[] = __('Group with the same name already exist.', LTW_TES_UNIQUE_NAME);
|
|
||||||
$ltw_tes_error_found = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No errors found, we can add this Group to the table
|
|
||||||
if ($ltw_tes_error_found == FALSE)
|
|
||||||
{
|
|
||||||
$sql = $wpdb->prepare(
|
|
||||||
"UPDATE `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
SET `group_name` = %s,
|
|
||||||
`page_id` = %d
|
|
||||||
WHERE id = %d
|
|
||||||
LIMIT 1",
|
|
||||||
array($form['ltw_tes_group_name'], $form['ltw_tes_page'], $ltw_tes_group_id)
|
|
||||||
);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
$ltw_tes_success = __('Testimonial group was successfully updated.', LTW_TES_UNIQUE_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
<h2><?php _e('Edit Testimonial Group', LTW_TES_UNIQUE_NAME); ?></h2>
|
|
||||||
<div id="ltw_tes_quick_links">
|
|
||||||
<?php include('quick_links_right.php'); ?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
if ($ltw_tes_error_found == TRUE && isset($ltw_tes_errors[0]) == TRUE)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="error fade"><p><strong><?php echo $ltw_tes_errors[0]; ?></strong></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ltw_tes_error_found == FALSE && strlen($ltw_tes_success) > 0)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="updated fade"><p><strong><?php echo $ltw_tes_success; ?></strong></p><p><a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonial_groups"><?php _e('Click here', LTW_TES_UNIQUE_NAME); ?></a> <?php _e('to go back to groups overview page', LTW_TES_UNIQUE_NAME); ?> <?php _e('or', LTW_TES_UNIQUE_NAME); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonial_groups&sp=add_new"><?php _e('click here', LTW_TES_UNIQUE_NAME); ?></a> <?php _e('to add another group.', LTW_TES_UNIQUE_NAME); ?></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<form method="post" action="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonial_groups&sp=edit&id=<?php echo $ltw_tes_group_id; ?>">
|
|
||||||
<div>
|
|
||||||
<input type="hidden" name="form_submit" value="yes"/>
|
|
||||||
<?php wp_nonce_field('ltw_tes_edit_group_form'); ?>
|
|
||||||
</div>
|
|
||||||
<table class="form-table">
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Group Name', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td><input type="text" name="ltw_tes_group_name" class="regular-text" value="<?php echo esc_html(stripslashes($form['ltw_tes_group_name'])); ?>" /></td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Testimonial Page', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td>
|
|
||||||
<select name="ltw_tes_page">
|
|
||||||
<option></option>
|
|
||||||
<?php
|
|
||||||
foreach (get_pages() as $key => $value)
|
|
||||||
{
|
|
||||||
$selected_page = '';
|
|
||||||
if ($form['ltw_tes_page'] == $value->ID)
|
|
||||||
{
|
|
||||||
$selected_page = ' selected="selected"';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<option value="<?php echo $value->ID; ?>"<?php echo $selected_page; ?>><?php echo $value->post_title; ?></option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
<br/>
|
|
||||||
<span class="description"><?php _e('This is the page where all the testimonials from this group will be shown. It is used for the "Show More" link in the widget.', LTW_TES_UNIQUE_NAME); ?></span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<p class="submit">
|
|
||||||
<input type="submit" class="button-primary" value="<?php _e('Update Group', LTW_TES_UNIQUE_NAME); ?>" />
|
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
@ -1,192 +0,0 @@
|
|||||||
<?php
|
|
||||||
$ltw_tes_show_success_msg = FALSE;
|
|
||||||
$ltw_tes_set_success_msg = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if "Bulk Action" was used
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if (isset($_POST['form_submit']) && $_POST['form_submit'] == 'yes')
|
|
||||||
{
|
|
||||||
if ((isset($_POST['action']) && $_POST['action'] == 'delete') || (isset($_POST['action2']) && $_POST['action2'] == 'delete'))
|
|
||||||
{
|
|
||||||
if (isset($_POST['ltw_tes_group_item']) && count($_POST['ltw_tes_group_item']) > 0)
|
|
||||||
{
|
|
||||||
// Just a little ;) security thingy that wordpress offers us
|
|
||||||
check_admin_referer('ltw_tes_groups_index');
|
|
||||||
|
|
||||||
foreach ($_POST['ltw_tes_group_item'] as $ltw_tes_group_item)
|
|
||||||
{
|
|
||||||
// Delete all selected records from the table
|
|
||||||
$sql = $wpdb->prepare("DELETE FROM `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
WHERE `id` = %d", $ltw_tes_group_item);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
// Also delete the testimonials that belong to this group
|
|
||||||
$sql = $wpdb->prepare("DELETE FROM `".LTW_TES_TESTIMONIALS_TABLE."`
|
|
||||||
WHERE `group_id` = %d", $ltw_tes_group_item);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
// Set success message
|
|
||||||
$ltw_tes_show_success_msg = TRUE;
|
|
||||||
$ltw_tes_set_success_msg = __('Selected groups were successfully deleted.', LTW_TES_UNIQUE_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if we are deleting a record.
|
|
||||||
* This is available per each testimonial group.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if (isset($_GET['sp']) && $_GET['sp'] == 'delete' && isset($_GET['id']) && $_GET['id'] != '')
|
|
||||||
{
|
|
||||||
// Just a little ;) security thingy that wordpress offers us
|
|
||||||
check_admin_referer('ltw_tes_delete_group');
|
|
||||||
|
|
||||||
// Delete selected record from the table
|
|
||||||
$sql = $wpdb->prepare("DELETE FROM `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
WHERE `id` = %d
|
|
||||||
LIMIT 1", $_GET['id']);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
// Also delete the testimonials that belong to this group
|
|
||||||
$sql = $wpdb->prepare("DELETE FROM `".LTW_TES_TESTIMONIALS_TABLE."`
|
|
||||||
WHERE `group_id` = %d", $_GET['id']);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
// Set success message
|
|
||||||
$ltw_tes_show_success_msg = TRUE;
|
|
||||||
$ltw_tes_set_success_msg = __('Selected record was successfully deleted.', LTW_TES_UNIQUE_NAME);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
<div class="metabox-holder" id="poststuff">
|
|
||||||
<h2><?php _e('Testimonial Groups', LTW_TES_UNIQUE_NAME); ?> <a class="button add-new-h2" href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonial_groups&sp=add_new"><?php _e('Add New Group', LTW_TES_UNIQUE_NAME); ?></a></h2>
|
|
||||||
<div id="ltw_tes_quick_links">
|
|
||||||
<?php include('quick_links_right.php'); ?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
if ($ltw_tes_show_success_msg == TRUE)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="updated fade"><p><strong><?php echo $ltw_tes_set_success_msg; ?></strong></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get all testimonial groups
|
|
||||||
$sql = "SELECT ltwg.*, ifnull(ltwt.`counter`, 0) AS `counter`
|
|
||||||
FROM `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."` AS ltwg
|
|
||||||
LEFT JOIN (
|
|
||||||
SELECT `group_id`, COUNT(*) AS `counter` FROM `".LTW_TES_TESTIMONIALS_TABLE."` GROUP BY `group_id`
|
|
||||||
) AS ltwt
|
|
||||||
ON
|
|
||||||
ltwg.`id` = ltwt.`group_id`
|
|
||||||
ORDER BY ltwg.`group_name` ASC";
|
|
||||||
$db_list = array();
|
|
||||||
$db_list = $wpdb->get_results($sql, ARRAY_A);
|
|
||||||
|
|
||||||
if (count($db_list) > 0)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<form action="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonial_groups" method="post">
|
|
||||||
<div>
|
|
||||||
<input type="hidden" name="form_submit" value="yes"/>
|
|
||||||
<?php wp_nonce_field('ltw_tes_groups_index'); ?>
|
|
||||||
</div>
|
|
||||||
<div class="tablenav">
|
|
||||||
<div class="alignleft actions">
|
|
||||||
<select name="action">
|
|
||||||
<option selected="selected" value=""><?php _e('Bulk Actions', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
<option value="delete"><?php _e('Delete', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
</select>
|
|
||||||
<input type="submit" class="button-secondary action" id="doaction" name="doaction" value="<?php _e('Apply', LTW_TES_UNIQUE_NAME); ?>">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<table class="widefat fixed" cellspacing="0">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col" id="cb" class="manage-column column-cb check-column"><input type="checkbox" /></th>
|
|
||||||
<th scope="col" id="name" class="manage-column column-title"><?php _e('Name', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="shortcode" class="manage-column column-title"><?php _e('Shortcode', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="count" class="manage-column column-visible"><?php _e('# of Testimonials', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th scope="col" id="cb2" class="manage-column column-cb check-column"><input type="checkbox" /></th>
|
|
||||||
<th scope="col" id="name2" class="manage-column column-title"><?php _e('Name', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="shortcode2" class="manage-column column-title"><?php _e('Shortcode', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="count2" class="manage-column column-visible"><?php _e('# of Testimonials', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
$alternate_row = 0;
|
|
||||||
|
|
||||||
foreach ($db_list as $list)
|
|
||||||
{
|
|
||||||
$alternate_row_class = ' alternate';
|
|
||||||
if ($alternate_row == 1)
|
|
||||||
{
|
|
||||||
$alternate_row_class = '';
|
|
||||||
$alternate_row = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$alternate_row++;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<tr class="iedit<?php echo $alternate_row_class; ?>">
|
|
||||||
<th class="check-column" scope="row"><input type="checkbox" value="<?php echo $list['id']; ?>" name="ltw_tes_group_item[]"></th>
|
|
||||||
<td class="column-title">
|
|
||||||
<strong><?php echo esc_html(stripslashes($list['group_name'])); ?></strong>
|
|
||||||
<div class="row-actions">
|
|
||||||
<span class="edit"><a title="<?php _e('Edit', LTW_TES_UNIQUE_NAME); ?>" href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonial_groups&sp=edit&id=<?php echo $list['id']; ?>"><?php _e('Edit', LTW_TES_UNIQUE_NAME); ?></a> | </span>
|
|
||||||
<?php
|
|
||||||
// Build nonce url
|
|
||||||
$ltw_tes_delete_group_url = wp_nonce_url(get_option('siteurl').'/wp-admin/admin.php?page=ltw_manage_testimonial_groups&sp=delete&id='.$list['id'], 'ltw_tes_delete_group');
|
|
||||||
?>
|
|
||||||
<span class="trash"><a href="<?php echo $ltw_tes_delete_group_url; ?>" title="<?php _e('Delete', LTW_TES_UNIQUE_NAME); ?>" class="submitdelete"><?php _e('Delete', LTW_TES_UNIQUE_NAME); ?></a></span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="column-title">[testimonial group="<?php echo $list['id']; ?>"]</td>
|
|
||||||
<td class="column-visible"><?php echo $list['counter']; ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="tablenav">
|
|
||||||
<div class="alignleft actions">
|
|
||||||
<select name="action2">
|
|
||||||
<option selected="selected" value=""><?php _e('Bulk Actions', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
<option value="delete"><?php _e('Delete', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
</select>
|
|
||||||
<input type="submit" class="button-secondary action" id="doaction" name="doaction" value="<?php _e('Apply', LTW_TES_UNIQUE_NAME); ?>">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<p class="description"><?php _e('Deleting a group also deletes all the testimonials that belong to the group.', LTW_TES_UNIQUE_NAME); ?></p><br />
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<p><?php _e('No testimonial groups found.', LTW_TES_UNIQUE_NAME); ?></p>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="postbox">
|
|
||||||
<div title="Click to toggle" class="handlediv"><br></div>
|
|
||||||
<h3 class="hndle"><span>Note:</span></h3>
|
|
||||||
<div class="inside">
|
|
||||||
<p>To display all the testimonials from all the groups, use [show_all_testimonials] shortcode in a page or post.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@ -1,401 +0,0 @@
|
|||||||
<?php
|
|
||||||
$ltw_tes_show_success_msg = FALSE;
|
|
||||||
$ltw_tes_set_success_msg = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if "Bulk Action" was used
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if (isset($_POST['form_submit']) && $_POST['form_submit'] == 'yes')
|
|
||||||
{
|
|
||||||
if ((isset($_POST['action']) && $_POST['action'] == 'delete') || (isset($_POST['action2']) && $_POST['action2'] == 'delete'))
|
|
||||||
{
|
|
||||||
if (isset($_POST['ltw_tes_testimonial_item']) && count($_POST['ltw_tes_testimonial_item']) > 0)
|
|
||||||
{
|
|
||||||
// Just a little ;) security thingy that wordpress offers us
|
|
||||||
check_admin_referer('ltw_tes_index');
|
|
||||||
|
|
||||||
foreach ($_POST['ltw_tes_testimonial_item'] as $ltw_tes_testimonial_item)
|
|
||||||
{
|
|
||||||
// Delete all selected records from the table
|
|
||||||
$sql = $wpdb->prepare("DELETE FROM `".LTW_TES_TESTIMONIALS_TABLE."`
|
|
||||||
WHERE `id` = %d", $ltw_tes_testimonial_item);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
// Set success message
|
|
||||||
$ltw_tes_show_success_msg = TRUE;
|
|
||||||
$ltw_tes_set_success_msg = __('Selected client testimonials were successfully deleted.', LTW_TES_UNIQUE_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if we are deleting a record.
|
|
||||||
* This is available per each testimonial group.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if (isset($_GET['sp']) && $_GET['sp'] == 'delete' && isset($_GET['id']) && $_GET['id'] != '')
|
|
||||||
{
|
|
||||||
// Just a little ;) security thingy that wordpress offers us
|
|
||||||
check_admin_referer('ltw_tes_delete_testimonial');
|
|
||||||
|
|
||||||
// Delete selected record from the table
|
|
||||||
$sql = $wpdb->prepare("DELETE FROM `".LTW_TES_TESTIMONIALS_TABLE."`
|
|
||||||
WHERE `id` = %d
|
|
||||||
LIMIT 1", $_GET['id']);
|
|
||||||
$wpdb->query($sql);
|
|
||||||
|
|
||||||
// Set success message
|
|
||||||
$ltw_tes_show_success_msg = TRUE;
|
|
||||||
$ltw_tes_set_success_msg = __('Selected client testimonial was successfully deleted.', LTW_TES_UNIQUE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Group filter stuff.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$ltw_group_qs = isset($_GET['filter']) ? '&filter='.$_GET['filter'] : '&filter=0';
|
|
||||||
$ltw_group_sql_id = isset($_GET['filter']) ? $_GET['filter'] : '0';
|
|
||||||
|
|
||||||
if (isset($_POST['form_submit']) && $_POST['form_submit'] == 'yes')
|
|
||||||
{
|
|
||||||
if ((isset($_POST['ltw_group_filter_action']) && strlen($_POST['ltw_group_filter_action']) > 0) || (isset($_POST['ltw_group_filter_action2']) && strlen($_POST['ltw_group_filter_action2']) > 0))
|
|
||||||
{
|
|
||||||
// Just a little ;) security thingy that wordpress offers us
|
|
||||||
check_admin_referer('ltw_tes_index');
|
|
||||||
|
|
||||||
if (isset($_POST['ltw_group_filter']) == TRUE && $_POST['ltw_group_filter'] != '0' && isset($_POST['ltw_group_filter_action']) == TRUE)
|
|
||||||
{
|
|
||||||
// Create the query string for filter
|
|
||||||
$ltw_group_qs = '&filter='.$_POST['ltw_group_filter'];
|
|
||||||
$ltw_group_sql_id = $_POST['ltw_group_filter'];
|
|
||||||
}
|
|
||||||
else if (isset($_POST['ltw_group_filter']) == TRUE && $_POST['ltw_group_filter'] == '0' && isset($_POST['ltw_group_filter_action']) == TRUE)
|
|
||||||
{
|
|
||||||
// Create the query string for filter
|
|
||||||
$ltw_group_qs = '';
|
|
||||||
$ltw_group_sql_id = 0;
|
|
||||||
}
|
|
||||||
else if (isset($_POST['ltw_group_filter2']) == TRUE && $_POST['ltw_group_filter2'] != '0' && isset($_POST['ltw_group_filter_action2']) == TRUE)
|
|
||||||
{
|
|
||||||
// Create the query string for filter
|
|
||||||
$ltw_group_qs = '&filter='.$_POST['ltw_group_filter2'];
|
|
||||||
$ltw_group_sql_id = $_POST['ltw_group_filter2'];
|
|
||||||
}
|
|
||||||
else if (isset($_POST['ltw_group_filter2']) == TRUE && $_POST['ltw_group_filter2'] == '0' && isset($_POST['ltw_group_filter_action2']) == TRUE)
|
|
||||||
{
|
|
||||||
// Create the query string for filter
|
|
||||||
$ltw_group_qs = '';
|
|
||||||
$ltw_group_sql_id = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<script type="text/javascript">
|
|
||||||
/* <![CDATA[ */
|
|
||||||
jQuery(document).ready(function($){
|
|
||||||
$(".ltw_show_full_tes").live('click', function(){
|
|
||||||
$(this).attr("class", "ltw_hide_full_tes");
|
|
||||||
$("#more_"+$(this).attr('id')).hide();
|
|
||||||
$("#full_"+$(this).attr('id')).show();
|
|
||||||
$(this).html("<?php _e('Hide full testimonial', LTW_TES_UNIQUE_NAME); ?>");
|
|
||||||
});
|
|
||||||
$(".ltw_hide_full_tes").live('click', function(){
|
|
||||||
$(this).attr("class", "ltw_show_full_tes");
|
|
||||||
$("#more_"+$(this).attr('id')).show();
|
|
||||||
$("#full_"+$(this).attr('id')).hide();
|
|
||||||
$(this).html("<?php _e('Show full testimonial', LTW_TES_UNIQUE_NAME); ?>");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
/* ]]> */
|
|
||||||
</script>
|
|
||||||
<div class="wrap">
|
|
||||||
<h2><?php _e('Testimonials', LTW_TES_UNIQUE_NAME); ?> <a class="button add-new-h2" href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonials&sp=add_new"><?php _e('Add New Testimonial', LTW_TES_UNIQUE_NAME); ?></a></h2>
|
|
||||||
<div id="ltw_tes_quick_links">
|
|
||||||
<?php include('quick_links_right.php'); ?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
include(ABSPATH.'/wp-content/plugins/'.LTW_TES_FOLDER_NAME.'/pagination.class.php');
|
|
||||||
|
|
||||||
$ltw_group_sql = '';
|
|
||||||
|
|
||||||
if ($ltw_group_sql_id != '0')
|
|
||||||
{
|
|
||||||
$ltw_group_sql = ' WHERE g.`id` = %d ';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get all testimonials
|
|
||||||
$sql = $wpdb->prepare("SELECT COUNT(tes.`id`) AS counter
|
|
||||||
FROM `".LTW_TES_TESTIMONIALS_TABLE."` AS tes
|
|
||||||
LEFT JOIN `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."` AS g ON (g.`id` = tes.`group_id`)
|
|
||||||
".$ltw_group_sql,
|
|
||||||
array($ltw_group_sql_id)
|
|
||||||
);
|
|
||||||
$ltw_testimonials_count = '';
|
|
||||||
$ltw_testimonials_count = $wpdb->get_results($sql, ARRAY_A);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all available groups
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$sql = "SELECT `id`, `group_name`, `page_id`
|
|
||||||
FROM `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."`
|
|
||||||
ORDER BY `group_name` ASC";
|
|
||||||
$ltw_tes_group_info = array();
|
|
||||||
$ltw_tes_group_info = $wpdb->get_results($sql, ARRAY_A);
|
|
||||||
|
|
||||||
if ($ltw_testimonials_count[0]['counter'] > 0)
|
|
||||||
{
|
|
||||||
$p = new pagination;
|
|
||||||
$p->items($ltw_testimonials_count[0]['counter']);
|
|
||||||
$p->limit(10); // Limit entries per page
|
|
||||||
$p->target("admin.php?page=ltw_manage_testimonials".$ltw_group_qs);
|
|
||||||
$p->currentPage($_GET[$p->paging]); // Gets and validates the current page
|
|
||||||
$p->calculate(); // Calculates what to show
|
|
||||||
$p->parameterName('paging');
|
|
||||||
$p->adjacents(1); //No. of page away from the current page
|
|
||||||
|
|
||||||
if(!isset($_GET['paging']))
|
|
||||||
{
|
|
||||||
$p->page = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$p->page = $_GET['paging'];
|
|
||||||
}
|
|
||||||
|
|
||||||
//Query for limit paging
|
|
||||||
$ltw_limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
|
|
||||||
|
|
||||||
if (get_option('ltw_tes_sort_testimonials') == '1')
|
|
||||||
{
|
|
||||||
$ltw_tes_order_by = ' ORDER BY tes.`id` DESC ';
|
|
||||||
}
|
|
||||||
else if (get_option('ltw_tes_sort_testimonials') == '2')
|
|
||||||
{
|
|
||||||
$ltw_tes_order_by = ' ORDER BY tes.`id` ASC ';
|
|
||||||
}
|
|
||||||
else if (get_option('ltw_tes_sort_testimonials') == '3')
|
|
||||||
{
|
|
||||||
//$ltw_tes_order_by = ' ORDER BY tes.`order` ASC ';
|
|
||||||
$ltw_tes_order_by = ' ORDER BY IF(`order` > 0, `order`, 1000000), `order` ASC ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = $wpdb->prepare("SELECT tes.`id`, tes.`testimonial`, tes.`client_name`, tes.`client_website`, tes.`client_company`, tes.`order`, tes.`group_id`, tes.`show_in_widget`, tes.`client_pic`,
|
|
||||||
g.`group_name`
|
|
||||||
FROM `".LTW_TES_TESTIMONIALS_TABLE."` AS tes
|
|
||||||
LEFT JOIN `".LTW_TES_TESTIMONIAL_GROUPS_TABLE."` AS g ON (g.`id` = tes.`group_id`)
|
|
||||||
".$ltw_group_sql."
|
|
||||||
".$ltw_tes_order_by."
|
|
||||||
".$ltw_limit."",
|
|
||||||
array($ltw_group_sql_id)
|
|
||||||
);
|
|
||||||
$ltw_testimonials_list = array();
|
|
||||||
$ltw_testimonials_list = $wpdb->get_results($sql, ARRAY_A);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<form action="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonials<?php echo $ltw_group_qs; ?>" method="post">
|
|
||||||
<div>
|
|
||||||
<input type="hidden" name="form_submit" value="yes"/>
|
|
||||||
<?php wp_nonce_field('ltw_tes_index'); ?>
|
|
||||||
</div>
|
|
||||||
<div class="tablenav">
|
|
||||||
<div class="alignleft actions">
|
|
||||||
<select name="action">
|
|
||||||
<option selected="selected" value=""><?php _e('Bulk Actions', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
<option value="delete"><?php _e('Delete', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
</select>
|
|
||||||
<input type="submit" class="button-secondary action" id="doaction" name="doaction" value="<?php _e('Apply', LTW_TES_UNIQUE_NAME); ?>">
|
|
||||||
<?php _e('Show testimonials from group', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
<select name="ltw_group_filter">
|
|
||||||
<option value="0"><?php _e('All', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
<?php
|
|
||||||
if (count($ltw_tes_group_info) > 0)
|
|
||||||
{
|
|
||||||
foreach ($ltw_tes_group_info as $group)
|
|
||||||
{
|
|
||||||
$ltw_group_selected = '';
|
|
||||||
if ($group['id'] == $ltw_group_sql_id)
|
|
||||||
{
|
|
||||||
$ltw_group_selected = ' selected="selected"';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<option value="<?php echo $group['id']; ?>"<?php echo $ltw_group_selected; ?>><?php echo $group['group_name']; ?></option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
</select>
|
|
||||||
<input type="submit" class="button-secondary action" id="ltw_group_filter_action" name="ltw_group_filter_action" value="<?php _e('Filter', LTW_TES_UNIQUE_NAME); ?>">
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
if ($ltw_testimonials_count[0]['counter'] > 0)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="alignright">
|
|
||||||
<?php echo $p->show(); ?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<table class="widefat fixed" cellspacing="0">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col" id="cb" class="manage-column column-cb check-column"><input type="checkbox" /></th>
|
|
||||||
<th scope="col" id="client_name" class="manage-column column-title"><?php _e('Client Name', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="client_testimonial" class="manage-column column-title"><?php _e('Testimonial', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="client_group" class="manage-column column-title"><?php _e('Group', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="show_in_widget" class="manage-column column-visible"><?php _e('Show in Widget', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="order" class="manage-column column-visible"><?php _e('Order', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th scope="col" id="cb2" class="manage-column column-cb check-column"><input type="checkbox" /></th>
|
|
||||||
<th scope="col" id="client_name2" class="manage-column column-title"><?php _e('Client Name', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="client_testimonial2" class="manage-column column-title"><?php _e('Testimonial', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="client_group2" class="manage-column column-title"><?php _e('Group', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="show_in_widget2" class="manage-column column-visible"><?php _e('Show in Widget', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<th scope="col" id="order2" class="manage-column column-visible"><?php _e('Order', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
if ($ltw_testimonials_count[0]['counter'] > 0)
|
|
||||||
{
|
|
||||||
$alternate_row = 0;
|
|
||||||
|
|
||||||
foreach ($ltw_testimonials_list as $list)
|
|
||||||
{
|
|
||||||
$alternate_row_class = ' alternate';
|
|
||||||
if ($alternate_row == 1)
|
|
||||||
{
|
|
||||||
$alternate_row_class = '';
|
|
||||||
$alternate_row = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$alternate_row++;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<tr class="iedit<?php echo $alternate_row_class; ?>">
|
|
||||||
<th class="check-column" scope="row"><input type="checkbox" value="<?php echo $list['id']; ?>" name="ltw_tes_testimonial_item[]"></th>
|
|
||||||
<td class="column-title">
|
|
||||||
<?php
|
|
||||||
if ($list['client_pic'] != '' && $list['client_pic'] != 'http://')
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<img style="float:left;width:48px;height:48px;margin-right:10px;" src="<?php echo esc_html(stripslashes($list['client_pic'])); ?>"/>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<strong><?php echo esc_html(stripslashes($list['client_name'])); ?></strong>
|
|
||||||
<?php
|
|
||||||
if ($list['client_website'] != '' && $list['client_website'] != 'http://')
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<br />
|
|
||||||
<a href="<?php echo esc_html(stripslashes($list['client_website'])); ?>"><?php echo esc_html(stripslashes($list['client_website'])); ?></a>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="row-actions">
|
|
||||||
<span class="edit"><a title="<?php _e('Edit', LTW_TES_UNIQUE_NAME); ?>" href="<?php echo get_option('siteurl'); ?>/wp-admin/admin.php?page=ltw_manage_testimonials&sp=edit&id=<?php echo $list['id']; ?>"><?php _e('Edit', LTW_TES_UNIQUE_NAME); ?></a> | </span>
|
|
||||||
<?php
|
|
||||||
// Build nonce url
|
|
||||||
$ltw_tes_delete_group_url = wp_nonce_url(get_option('siteurl').'/wp-admin/admin.php?page=ltw_manage_testimonials&sp=delete&id='.$list['id'], 'ltw_tes_delete_testimonial');
|
|
||||||
?>
|
|
||||||
<span class="trash"><a href="<?php echo $ltw_tes_delete_group_url; ?>" title="<?php _e('Delete', LTW_TES_UNIQUE_NAME); ?>" class="submitdelete"><?php _e('Delete', LTW_TES_UNIQUE_NAME); ?></a></span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="column-title">
|
|
||||||
<?php
|
|
||||||
if (strlen($list['testimonial']) > 200)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div id="ltw_testimonial_limited">
|
|
||||||
<?php echo stripslashes(substr($list['testimonial'], 0, 200)); ?><span class="ltw_testimonial_more" id="more_ltw_<?php echo $list['id']; ?>">...</span><span class="ltw_testimonial_full" id="full_ltw_<?php echo $list['id']; ?>" style="display: none;"><?php echo substr(stripslashes($list['testimonial']), 200); ?></span>
|
|
||||||
</div>
|
|
||||||
<div class="row-actions" id="ltw_testimonial_action_show">
|
|
||||||
<span class="edit"><a href="#" class="ltw_show_full_tes" id="ltw_<?php echo $list['id']; ?>" onclick="return false;"><?php _e('Show full testimonial', LTW_TES_UNIQUE_NAME); ?></a></span>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo stripslashes($list['testimonial']);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</td>
|
|
||||||
<td class="column-title"><?php echo esc_html(stripslashes($list['group_name'])); ?></td>
|
|
||||||
<td class="column-visible">
|
|
||||||
<input type="checkbox" name="ltw_tes_show_in_widget" class="ltw_tes_show_in_widget" value="<?php echo $list['id']; ?>"<?php echo $list['show_in_widget'] == '1' ? ' checked="checked"' : ''; ?>/>
|
|
||||||
<br />
|
|
||||||
<img alt="" src="<?php echo bloginfo('url'); ?>/wp-admin/images/wpspin_light.gif" id="ltw_waiting_<?php echo $list['id']; ?>" class="waiting" style="display: none;">
|
|
||||||
</td>
|
|
||||||
<td class="column-visible">
|
|
||||||
<input type="text" name="ltw_tes_order" class="ltw_tes_order" id="order_update_<?php echo $list['id']; ?>" value="<?php echo esc_html(stripslashes($list['order'])); ?>" style="width: 50px;" />
|
|
||||||
<br />
|
|
||||||
<img alt="" src="<?php echo bloginfo('url'); ?>/wp-admin/images/wpspin_light.gif" id="waiting_order_update_<?php echo $list['id']; ?>" class="waiting" style="display: none;">
|
|
||||||
<input type="button" value="Update" id="update_<?php echo $list['id']; ?>" name="ltw_tes_update_order" class="button-secondary ltw_tes_update">
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<tr><td colspan="5"><p><strong><?php _e('No testimonials found.', LTW_TES_UNIQUE_NAME); ?></strong></p></td></tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="tablenav">
|
|
||||||
<div class="alignleft actions">
|
|
||||||
<select name="action2">
|
|
||||||
<option selected="selected" value=""><?php _e('Bulk Actions', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
<option value="delete"><?php _e('Delete', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
</select>
|
|
||||||
<input type="submit" class="button-secondary action" id="doaction2" name="doaction" value="<?php _e('Apply', LTW_TES_UNIQUE_NAME); ?>">
|
|
||||||
<?php _e('Show testimonials from group', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
<select name="ltw_group_filter2">
|
|
||||||
<option value="0"><?php _e('All', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
<?php
|
|
||||||
if (count($ltw_tes_group_info) > 0)
|
|
||||||
{
|
|
||||||
foreach ($ltw_tes_group_info as $group)
|
|
||||||
{
|
|
||||||
$ltw_group_selected = '';
|
|
||||||
if ($group['id'] == $ltw_group_sql_id)
|
|
||||||
{
|
|
||||||
$ltw_group_selected = ' selected="selected"';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<option value="<?php echo $group['id']; ?>"<?php echo $ltw_group_selected; ?>><?php echo $group['group_name']; ?></option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
</select>
|
|
||||||
<input type="submit" class="button-secondary action" id="ltw_group_filter_action2" name="ltw_group_filter_action2" value="<?php _e('Filter', LTW_TES_UNIQUE_NAME); ?>">
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
if ($ltw_testimonials_count[0]['counter'] > 0)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div class="alignright">
|
|
||||||
<?php echo $p->show(); ?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<p class="description"><?php _e('Image is resized to 48x48px for this page.', LTW_TES_UNIQUE_NAME); ?></p>
|
|
||||||
</div>
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
<div class="wrap">
|
|
||||||
<h2><?php _e('Testimonial Settings', LTW_TES_UNIQUE_NAME); ?></h2>
|
|
||||||
<div id="ltw_tes_quick_links">
|
|
||||||
<?php include('quick_links_right.php'); ?>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
if ($_GET['updated'] == 'true')
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<div id="message" class="updated fade"><p><strong><?php _e('Settings Updated', LTW_TES_UNIQUE_NAME); ?></strong></p></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<form method="post" action="<?php echo get_option('siteurl'); ?>/wp-admin/options.php">
|
|
||||||
<div>
|
|
||||||
<?php settings_fields('ltw-testimonials-settings'); ?>
|
|
||||||
</div>
|
|
||||||
<table class="form-table">
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Sort testimonials on page by', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td>
|
|
||||||
<select name="ltw_tes_sort_testimonials">
|
|
||||||
<option value="1"<?php echo get_option('ltw_tes_sort_testimonials') == '1' ? ' selected="selected"' : ''; ?>><?php _e('Newest testimonials first', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
<option value="2"<?php echo get_option('ltw_tes_sort_testimonials') == '2' ? ' selected="selected"' : ''; ?>><?php _e('Older testimonials first', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
<option value="3"<?php echo get_option('ltw_tes_sort_testimonials') == '3' ? ' selected="selected"' : ''; ?>><?php _e('User defined', LTW_TES_UNIQUE_NAME); ?></option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Remove data when deactivating plugin', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td>
|
|
||||||
<input type="checkbox" name="ltw_tes_delete_tables" value="1"<?php echo get_option('ltw_tes_delete_tables') == '1' ? ' checked="checked"' : ''; ?>/> <?php _e('All testimonials, groups and other settings will be deleted!', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><?php _e('Promote this plugin', LTW_TES_UNIQUE_NAME); ?></th>
|
|
||||||
<td>
|
|
||||||
<input type="checkbox" name="ltw_tes_promote_plugin" value="1"<?php echo get_option('ltw_tes_promote_plugin') == '1' ? ' checked="checked"' : ''; ?>/> <?php _e('A link will be added to the end of the testimonial list.', LTW_TES_UNIQUE_NAME); ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<p class="submit"><input type="submit" class="button-primary" value="<?php _e('Update', LTW_TES_UNIQUE_NAME); ?>" /></p>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
@ -1,204 +0,0 @@
|
|||||||
<?php
|
|
||||||
class pagination{
|
|
||||||
/*
|
|
||||||
Script Name: *Digg Style Paginator Class
|
|
||||||
Script URI: http://www.mis-algoritmos.com/2007/05/27/digg-style-pagination-class/
|
|
||||||
Description: Class in PHP that allows to use a pagination like a digg or sabrosus style.
|
|
||||||
Script Version: 0.4
|
|
||||||
Author: Victor De la Rocha
|
|
||||||
Author URI: http://www.mis-algoritmos.com
|
|
||||||
*/
|
|
||||||
/*Default values*/
|
|
||||||
var $total_pages = -1;//items
|
|
||||||
var $limit = null;
|
|
||||||
var $target = "";
|
|
||||||
var $page = 1;
|
|
||||||
var $adjacents = 2;
|
|
||||||
var $showCounter = false;
|
|
||||||
var $className = "pagination";
|
|
||||||
var $parameterName = "page";
|
|
||||||
var $urlF = false;//urlFriendly
|
|
||||||
|
|
||||||
/*Buttons next and previous*/
|
|
||||||
var $nextT = "Next";
|
|
||||||
var $nextI = "»"; //►
|
|
||||||
var $prevT = "Previous";
|
|
||||||
var $prevI = "«"; //◄
|
|
||||||
|
|
||||||
/*****/
|
|
||||||
var $calculate = false;
|
|
||||||
|
|
||||||
#Total items
|
|
||||||
function items($value){$this->total_pages = (int) $value;}
|
|
||||||
|
|
||||||
#how many items to show per page
|
|
||||||
function limit($value){$this->limit = (int) $value;}
|
|
||||||
|
|
||||||
#Page to sent the page value
|
|
||||||
function target($value){$this->target = $value;}
|
|
||||||
|
|
||||||
#Current page
|
|
||||||
function currentPage($value){$this->page = (int) $value;}
|
|
||||||
|
|
||||||
#How many adjacent pages should be shown on each side of the current page?
|
|
||||||
function adjacents($value){$this->adjacents = (int) $value;}
|
|
||||||
|
|
||||||
#show counter?
|
|
||||||
function showCounter($value=""){$this->showCounter=($value===true)?true:false;}
|
|
||||||
|
|
||||||
#to change the class name of the pagination div
|
|
||||||
function changeClass($value=""){$this->className=$value;}
|
|
||||||
|
|
||||||
function nextLabel($value){$this->nextT = $value;}
|
|
||||||
function nextIcon($value){$this->nextI = $value;}
|
|
||||||
function prevLabel($value){$this->prevT = $value;}
|
|
||||||
function prevIcon($value){$this->prevI = $value;}
|
|
||||||
|
|
||||||
#to change the class name of the pagination div
|
|
||||||
function parameterName($value=""){$this->parameterName=$value;}
|
|
||||||
|
|
||||||
#to change urlFriendly
|
|
||||||
function urlFriendly($value="%"){
|
|
||||||
if(eregi('^ *$',$value)){
|
|
||||||
$this->urlF=false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$this->urlF=$value;
|
|
||||||
}
|
|
||||||
|
|
||||||
var $pagination;
|
|
||||||
|
|
||||||
function pagination(){}
|
|
||||||
function show(){
|
|
||||||
if(!$this->calculate)
|
|
||||||
if($this->calculate())
|
|
||||||
echo "<div class=\"$this->className\">$this->pagination</div>\n";
|
|
||||||
}
|
|
||||||
function getOutput(){
|
|
||||||
if(!$this->calculate)
|
|
||||||
if($this->calculate())
|
|
||||||
return "<div class=\"$this->className\">$this->pagination</div>\n";
|
|
||||||
}
|
|
||||||
function get_pagenum_link($id){
|
|
||||||
if(strpos($this->target,'?')===false)
|
|
||||||
if($this->urlF)
|
|
||||||
return str_replace($this->urlF,$id,$this->target);
|
|
||||||
else
|
|
||||||
return "$this->target?$this->parameterName=$id";
|
|
||||||
else
|
|
||||||
return "$this->target&$this->parameterName=$id";
|
|
||||||
}
|
|
||||||
|
|
||||||
function calculate(){
|
|
||||||
$this->pagination = "";
|
|
||||||
$this->calculate == true;
|
|
||||||
$error = false;
|
|
||||||
if($this->urlF and $this->urlF != '%' and strpos($this->target,$this->urlF)===false){
|
|
||||||
//Es necesario especificar el comodin para sustituir
|
|
||||||
echo "Especificaste un wildcard para sustituir, pero no existe en el target<br />";
|
|
||||||
$error = true;
|
|
||||||
}elseif($this->urlF and $this->urlF == '%' and strpos($this->target,$this->urlF)===false){
|
|
||||||
echo "Es necesario especificar en el target el comodin % para sustituir el número de página<br />";
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->total_pages < 0){
|
|
||||||
echo "It is necessary to specify the <strong>number of pages</strong> (\$class->items(1000))<br />";
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
if($this->limit == null){
|
|
||||||
echo "It is necessary to specify the <strong>limit of items</strong> to show per page (\$class->limit(10))<br />";
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
if($error)return false;
|
|
||||||
|
|
||||||
$n = trim($this->nextT.' '.$this->nextI);
|
|
||||||
$p = trim($this->prevI.' '.$this->prevT);
|
|
||||||
|
|
||||||
/* Setup vars for query. */
|
|
||||||
if($this->page)
|
|
||||||
$start = ($this->page - 1) * $this->limit; //first item to display on this page
|
|
||||||
else
|
|
||||||
$start = 0; //if no page var is given, set start to 0
|
|
||||||
|
|
||||||
/* Setup page vars for display. */
|
|
||||||
$prev = $this->page - 1; //previous page is page - 1
|
|
||||||
$next = $this->page + 1; //next page is page + 1
|
|
||||||
$lastpage = ceil($this->total_pages/$this->limit); //lastpage is = total pages / items per page, rounded up.
|
|
||||||
$lpm1 = $lastpage - 1; //last page minus 1
|
|
||||||
|
|
||||||
/*
|
|
||||||
Now we apply our rules and draw the pagination object.
|
|
||||||
We're actually saving the code to a variable in case we want to draw it more than once.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if($lastpage > 1){
|
|
||||||
if($this->page){
|
|
||||||
//anterior button
|
|
||||||
if($this->page > 1)
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link($prev)."\" class=\"prev\">$p</a>";
|
|
||||||
else
|
|
||||||
$this->pagination .= "<span class=\"disabled\">$p</span>";
|
|
||||||
}
|
|
||||||
//pages
|
|
||||||
if ($lastpage < 7 + ($this->adjacents * 2)){//not enough pages to bother breaking it up
|
|
||||||
for ($counter = 1; $counter <= $lastpage; $counter++){
|
|
||||||
if ($counter == $this->page)
|
|
||||||
$this->pagination .= "<span class=\"current\">$counter</span>";
|
|
||||||
else
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif($lastpage > 5 + ($this->adjacents * 2)){//enough pages to hide some
|
|
||||||
//close to beginning; only hide later pages
|
|
||||||
if($this->page < 1 + ($this->adjacents * 2)){
|
|
||||||
for ($counter = 1; $counter < 4 + ($this->adjacents * 2); $counter++){
|
|
||||||
if ($counter == $this->page)
|
|
||||||
$this->pagination .= "<span class=\"current\">$counter</span>";
|
|
||||||
else
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
|
|
||||||
}
|
|
||||||
$this->pagination .= "...";
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link($lpm1)."\">$lpm1</a>";
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link($lastpage)."\">$lastpage</a>";
|
|
||||||
}
|
|
||||||
//in middle; hide some front and some back
|
|
||||||
elseif($lastpage - ($this->adjacents * 2) > $this->page && $this->page > ($this->adjacents * 2)){
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link(1)."\">1</a>";
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link(2)."\">2</a>";
|
|
||||||
$this->pagination .= "...";
|
|
||||||
for ($counter = $this->page - $this->adjacents; $counter <= $this->page + $this->adjacents; $counter++)
|
|
||||||
if ($counter == $this->page)
|
|
||||||
$this->pagination .= "<span class=\"current\">$counter</span>";
|
|
||||||
else
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
|
|
||||||
$this->pagination .= "...";
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link($lpm1)."\">$lpm1</a>";
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link($lastpage)."\">$lastpage</a>";
|
|
||||||
}
|
|
||||||
//close to end; only hide early pages
|
|
||||||
else{
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link(1)."\">1</a>";
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link(2)."\">2</a>";
|
|
||||||
$this->pagination .= "...";
|
|
||||||
for ($counter = $lastpage - (2 + ($this->adjacents * 2)); $counter <= $lastpage; $counter++)
|
|
||||||
if ($counter == $this->page)
|
|
||||||
$this->pagination .= "<span class=\"current\">$counter</span>";
|
|
||||||
else
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($this->page){
|
|
||||||
//siguiente button
|
|
||||||
if ($this->page < $counter - 1)
|
|
||||||
$this->pagination .= "<a href=\"".$this->get_pagenum_link($next)."\" class=\"next\">$n</a>";
|
|
||||||
else
|
|
||||||
$this->pagination .= "<span class=\"disabled\">$n</span>";
|
|
||||||
if($this->showCounter)$this->pagination .= "<div class=\"pagination_data\">($this->total_pages Pages)</div>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
@ -1,89 +0,0 @@
|
|||||||
=== LTW Testimonials ===
|
|
||||||
Contributors: LessThanWeb
|
|
||||||
Donate link: http://www.lessthanweb.com/products/wp-plugin-ltw-testimonials
|
|
||||||
Tags: clients, testimonials, products, reviews
|
|
||||||
Requires at least: 2.9.1
|
|
||||||
Tested up to: 3.0.1
|
|
||||||
Stable tag: 1.3.0
|
|
||||||
|
|
||||||
LTW Testimonials is a powerful Wordpress plugin that will display client testimonials on your blog.
|
|
||||||
|
|
||||||
== Description ==
|
|
||||||
|
|
||||||
LTW Testimonials is a very simple yet very powerful plugin that will make your life easier when dealing with client testimonials.
|
|
||||||
|
|
||||||
You will be able to separate your client testimonials into unlimited number of groups which you can then display on different pages on a single blog installation.
|
|
||||||
|
|
||||||
Even if you have just one product or service, this will help you manage your testimonials much easier and quicker.
|
|
||||||
|
|
||||||
But that's not all. You can also customize the look and layout of the testimonials being displayed on the pages by simply editing the HTML and CSS code from the WP admin area itself.
|
|
||||||
|
|
||||||
It also comes with a widget where you can display random client testimonials.
|
|
||||||
|
|
||||||
== Installation ==
|
|
||||||
|
|
||||||
1. Download & extract plugin using its default folder
|
|
||||||
1. Upload plugin folder to the "/wp-content/plugins/" folder. If you're uploading it make sure to upload the top-level folder. Don't just upload all the php files and put them in `/wp-content/plugins/`
|
|
||||||
1. Activate the plugin through the "Plugins" menu in WordPress
|
|
||||||
1. That's it. A new option will be shown in the menu of the WP Admin area
|
|
||||||
|
|
||||||
== Frequently Asked Questions ==
|
|
||||||
|
|
||||||
You can find the FAQ at the [website](http://www.lessthanweb.com/products/wp-plugin-ltw-testimonials)
|
|
||||||
|
|
||||||
== Screenshots ==
|
|
||||||
|
|
||||||
1. Adding new client testimonial
|
|
||||||
2. Overview of the groups
|
|
||||||
|
|
||||||
== Changelog ==
|
|
||||||
* Version 1.3.0 (2010/11/02)
|
|
||||||
* The "More" link in the widget is now linked to that testimonial. In other words, it will scroll to the testimonial itself when the link is clicked
|
|
||||||
* Added new option to widget: Show client picture
|
|
||||||
|
|
||||||
* Version 1.2.1 (2010/10/25)
|
|
||||||
* Fixed a bug where new line was ignored
|
|
||||||
|
|
||||||
* Version 1.2.0 (2010/10/04)
|
|
||||||
* Added option to update the order from the client testimonial overview page
|
|
||||||
* Added option to update the "Show in Widget" checkbox from the client testimonial overview page
|
|
||||||
* Changed deactivation of the plugin. If you select to delete data, it will delete tables and also all other settings
|
|
||||||
* Added URL below the name of the client in the client testimonials overview page
|
|
||||||
* Added option to also upload client picture
|
|
||||||
* Added client picture to the client testimonials overview page if there is any
|
|
||||||
|
|
||||||
* Version 1.1.5 (2010/09/13)
|
|
||||||
* Fixed the CSS tag being shown as empty if the CSS from Design page is removed
|
|
||||||
* Fixed bug in the widget Show More url if Default permalinks structure is selected
|
|
||||||
* Added Show in Widget field to testimonials overview page
|
|
||||||
|
|
||||||
* Version 1.1.4 (2010/08/31)
|
|
||||||
* Fixed user defined sorting bug
|
|
||||||
* Fixed backslashes in the widget
|
|
||||||
|
|
||||||
* Version 1.1.3 (2010/08/28)
|
|
||||||
* Bug fixed when editing client testimonials. The text area had wrong name field.
|
|
||||||
|
|
||||||
* Version 1.1.2 (2010/08/24)
|
|
||||||
* Another bug fixed. It disabled adding new groups
|
|
||||||
|
|
||||||
* Version 1.1.1 (2010/08/24)
|
|
||||||
* Fixed a bug where the selected dropdown item on the Groups page of the add and edit form was not saved correctly
|
|
||||||
|
|
||||||
* Version 1.1.0 (2010/08/22)
|
|
||||||
* Added the donation link and changed the "Got a question?" link to "Support"
|
|
||||||
* Added option on the settings page to promote this plugin. It adds a little link "Powered by LTW Testimonials" at the bottom of the testimonials page
|
|
||||||
* Added "Set word limit" option to widget
|
|
||||||
* Added shortcode for displaying all the testimonials on one page
|
|
||||||
* Added option to widget to display only testimonials from one selected group
|
|
||||||
|
|
||||||
* Version 1.0.2 (2010/08/17)
|
|
||||||
* Fixed the wrong URL for the "Got a question?" link
|
|
||||||
* Added missing code for saving the two "show more" options in the widget
|
|
||||||
* Fixed the random bug in the widget
|
|
||||||
|
|
||||||
* Version 1.0.1 (2010/08/11)
|
|
||||||
* Fixed a bug that deleted HTML and CSS design if the settings page was updated
|
|
||||||
|
|
||||||
* Version 1.0 (2010/08/06)
|
|
||||||
* Initial version
|
|
||||||
|
Before Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 162 B |
|
Before Width: | Height: | Size: 164 B |
|
Before Width: | Height: | Size: 354 B |
|
Before Width: | Height: | Size: 494 B |
|
Before Width: | Height: | Size: 267 B |
|
Before Width: | Height: | Size: 372 B |
|
Before Width: | Height: | Size: 518 B |
|
Before Width: | Height: | Size: 374 B |
|
Before Width: | Height: | Size: 590 B |
|
Before Width: | Height: | Size: 477 B |
|
Before Width: | Height: | Size: 255 B |
|
Before Width: | Height: | Size: 336 B |
|
Before Width: | Height: | Size: 389 B |
|
Before Width: | Height: | Size: 477 B |
|
Before Width: | Height: | Size: 301 B |
|
Before Width: | Height: | Size: 337 B |
|
Before Width: | Height: | Size: 384 B |
|
Before Width: | Height: | Size: 551 B |
|
Before Width: | Height: | Size: 427 B |
|
Before Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 570 B |
|
Before Width: | Height: | Size: 365 B |
|
Before Width: | Height: | Size: 436 B |
|
Before Width: | Height: | Size: 362 B |
|
Before Width: | Height: | Size: 494 B |
|
Before Width: | Height: | Size: 378 B |
|
Before Width: | Height: | Size: 376 B |
|
Before Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 293 B |
|
Before Width: | Height: | Size: 252 B |
|
Before Width: | Height: | Size: 340 B |
|
Before Width: | Height: | Size: 552 B |
|
Before Width: | Height: | Size: 467 B |
|
Before Width: | Height: | Size: 290 B |
|
Before Width: | Height: | Size: 569 B |
|
Before Width: | Height: | Size: 575 B |
|
Before Width: | Height: | Size: 248 B |
|
Before Width: | Height: | Size: 560 B |
|
Before Width: | Height: | Size: 363 B |
|
Before Width: | Height: | Size: 527 B |
|
Before Width: | Height: | Size: 424 B |
|
Before Width: | Height: | Size: 311 B |
|
Before Width: | Height: | Size: 307 B |
|
Before Width: | Height: | Size: 567 B |
|
Before Width: | Height: | Size: 220 B |
|
Before Width: | Height: | Size: 403 B |
|
Before Width: | Height: | Size: 563 B |
|
Before Width: | Height: | Size: 570 B |
|
Before Width: | Height: | Size: 469 B |
|
Before Width: | Height: | Size: 355 B |
|
Before Width: | Height: | Size: 302 B |
|
Before Width: | Height: | Size: 329 B |
|
Before Width: | Height: | Size: 295 B |
|
Before Width: | Height: | Size: 581 B |
|
Before Width: | Height: | Size: 298 B |