= '3.5'){
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_style( 'wp-color-picker' );
}
else
{
wp_enqueue_style( 'farbtastic' );
wp_enqueue_script( 'farbtastic' );
}
wp_enqueue_script( 'advps-js-script', advps_url . 'js/advps.script.js', array( 'jquery' ) );
wp_localize_script( 'advps-js-script', 'advpsajx', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),'advpsAjaxReqChck' => wp_create_nonce( 'advpsauthrequst' )));
}
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
/* ---------------------------------------------------------------------------------------*/
register_activation_hook(WP_PLUGIN_DIR.'/advanced-post-slider/advanced-post-slider.php','set_advps_options');
register_deactivation_hook(WP_PLUGIN_DIR.'/advanced-post-slider/advanced-post-slider.php','unset_advps_options');
add_action( 'plugins_loaded', 'set_advps_options' );
function unset_advps_options(){
}
/* ---------------------------------------------------------------------------------------*/
function advps_image_sizes(){
if ( function_exists( 'add_image_size' ) ) {
global $wpdb;
$rth = $wpdb->get_results( "select * from ".$wpdb->prefix."advps_thumbnail");
foreach($rth as $th){
add_image_size( $th->thumb_name,$th->width,$th->height, true);
}
}
if(!function_exists('aq_resize') && !class_exists('Aq_Resize'))
require_once( 'aq_resizer.php' );
}
add_action('wp_loaded', 'advps_image_sizes');
function advps_excerpt_length_one( $length ) {
return get_option('advps_excerptlen_one');
}
function advps_excerpt_length( $length ) {
return get_option('advps_excerptlen');
}
add_action( "wp_ajax_chkCaetegory", "chkCaetegory" );
add_action( "wp_ajax_advpsUpdateLabel", "advpsUpdateLabel" );
add_action( "wp_ajax_advpsUpdateOpt", "advpsUpdateOpt" );
add_action( "wp_ajax_advpsListPost", "advpsListPost" );
add_action( "wp_ajax_advpsUpdateSmethod", "advpsUpdateSmethod" );
function advpsUpdateLabel(){
$nonce = $_POST['checkReq'];
$fname = $_POST['f_name'];
$fvalue = trim($_POST['f_value']);
if(! defined( 'ABSPATH' ) || !wp_verify_nonce( $nonce, 'advpsauthrequst' )){
echo "Unauthorized request.";
exit;
}
update_option($fname,$fvalue);
exit;
}
function advpsSanit($str){
return sanitize_text_field($str);
}
function chkCaetegory(){
$nonce = $_POST['checkReq'];
$posttype = $_POST['post_type'];
if(! defined( 'ABSPATH' ) || !wp_verify_nonce( $nonce, 'advpsauthrequst' )){
echo "Unauthorized request.";
exit;
}
$catHtml = '';
if($posttype == 'post'){
$catHtml = '
Category | [ * You can select multiple category ] | ';
}
else
{
$posttypeobj = get_post_type_object($posttype);
if(in_array('category',$posttypeobj->taxonomies)){
$catHtml = 'Category | [ * You can select multiple category ] | ';
}
}
echo $catHtml;
exit;
}
function advpsUpdateOpt(){
$nonce = $_POST['checkReq'];
$optdata = $_POST['optdata'];
if(! defined( 'ABSPATH' ) || !wp_verify_nonce( $nonce, 'advpsauthrequst' )){
echo "Unauthorized request.";
exit;
}
global $wpdb;
$all_field = array();
parse_str($optdata,$all_field);
$optID = sanitize_text_field($all_field['opt_id']);
$optfield = sanitize_text_field($all_field['opt_field']);
unset($all_field['opt_id']);
unset($all_field['opt_field']);
$update_data = array();
foreach($all_field as $fkey => $fval){
if(is_array($fval)){
$update_data[$fkey] = array_map('advpsSanit',$fval);
}
else
{
$update_data[$fkey] = sanitize_text_field($fval);
}
}
$update_data = serialize($update_data);
$q_chk = $wpdb->prepare("select template from ".$wpdb->prefix."advps_optionset where ".$optfield." = '%s' and id = %d",$update_data,$optID);
if(!$wpdb->get_results($q_chk)){
$q_upd = $wpdb->prepare("update ".$wpdb->prefix."advps_optionset set ".$optfield." = '%s' where id = %d",$update_data,$optID);
if($wpdb->query($q_upd)){
echo "Updated successfully.";
}
}
else
{
echo 'No change.';
}
exit;
}
function advpsListPost(){
$nonce = $_POST['checkReq'];
$ptype = $_POST['ptype'];
$pmax = $_POST['pmax'];
$porderBy = $_POST['porderBy'];
$porder = $_POST['porder'];
$plist = explode(',',$_POST['plist']);
if(! defined( 'ABSPATH' ) || !wp_verify_nonce( $nonce, 'advpsauthrequst' )){
echo "Unauthorized request.";
exit;
}
$plistHtml = '';
$lpargs = array(
'post_type' => $ptype,
'posts_per_page' => $pmax,
'orderby' => $porderBy,
'order' => $porder
);
$pl_query = new WP_Query($lpargs); while ($pl_query->have_posts()) : $pl_query->the_post();
if($plist && in_array(get_the_id(),$plist)){
$plistHtml .= '';
}
else{
$plistHtml .= '';
}
endwhile;wp_reset_query();
echo $plistHtml;
exit;
}
function advpsUpdateSmethod(){
$nonce = $_POST['checkReq'];
$selnam = $_POST['selnam'];
$selval = $_POST['selval'];
if(! defined( 'ABSPATH' ) || !wp_verify_nonce( $nonce, 'advpsauthrequst' )){
echo "Unauthorized request.";
exit;
}
update_option($selnam,$selval);
exit;
}
/* ---------------------------------------------------------------------------------------*/
function advps_slideshow($atts) {
global $post;
global $wpdb;
$current = $post->ID;
if(is_array($atts) && array_key_exists('optset',$atts)){
$q1 = "select * from ".$wpdb->prefix."advps_optionset where id = ".$atts['optset'];
$res1 = $wpdb->get_results($q1);
if($res1){
$plist = unserialize($res1[0]->plist);
$query = unserialize($res1[0]->query);
$slider = unserialize($res1[0]->slider);
$caro_ticker = unserialize($res1[0]->caro_ticker);
$container = unserialize($res1[0]->container);
$content = unserialize($res1[0]->content);
$navigation = unserialize($res1[0]->navigation);
}
else return;
$sldshowID = $atts['optset'];
}
else return;
if($query['advps_exclude']){
$exclude = explode(',',$query['advps_exclude']);
}
else
{
$exclude = '';
}
$qtype = get_option('advpssmethod'.$sldshowID);
if($qtype == 'query'){
$query_arg = array(
'post_type' => ($query['advps_post_types']) ? $query['advps_post_types'] : 'post',
'post__not_in' => $exclude,
'offset' => ($query['advps_offset']) ? $query['advps_offset'] : 0,
'posts_per_page' => ($query['advps_maxpost']) ? $query['advps_maxpost'] : 10,
'orderby' => ($query['advps_order_by']) ? $query['advps_order_by'] : 'date',
'order' => ($query['advps_order']) ? $query['advps_order'] : 'DESC'
);
if($query['advps_post_types'] && $query['advps_post_types'] != "page"){
if($query['advps_post_types'] == "post"){
if(isset($query['advps_category'])){
$query_arg['cat'] = implode(',',$query['advps_category']);
}
}
else
{
$post_type_obj = get_post_type_object( $query['advps_post_types'] );
if(in_array('category',$post_type_obj->taxonomies)){
if(isset($query['advps_category'])){
$query_arg['cat'] = implode(',',$query['advps_category']);
}
}
}
}
}
elseif($qtype == 'plist'){
$query_arg = array(
'post_type' => ($plist['advps_post_stypes']) ? $plist['advps_post_stypes'] : 'post',
'post__in' => $plist['advps_plist'],
'posts_per_page' => ($plist['advps_plistmax']) ? $plist['advps_plistmax'] : 10,
'orderby' => ($plist['advps_plistorder_by']) ? $plist['advps_plistorder_by'] : 'date',
'order' => ($plist['advps_plistorder']) ? $plist['advps_plistorder'] : 'DESC'
);
}
$template = $res1[0]->template;
if(($template == "one" || $template == "two") && !post_type_supports( $query['advps_post_types'], 'thumbnail' )){
return;
}
if($template != 'two'){
if($content['advps_excerptlen']){
update_option('advps_excerptlen',$content['advps_excerptlen']);
}
else
{
update_option('advps_excerptlen',30);
}
add_filter( 'excerpt_length', 'advps_excerpt_length', 999 );
}
ob_start();
?>
">
have_posts()) : $the_query->the_post();if($template == 'one'):
?>