1. <?php
  2. /**
  3. * Twenty Thirteen functions and definitions
  4. *
  5. * Sets up the theme and provides some helper functions, which are used in the
  6. * theme as custom template tags. Others are attached to action and filter
  7. * hooks in WordPress to change core functionality.
  8. *
  9. * When using a child theme (see https://codex.wordpress.org/Theme_Development
  10. * and https://codex.wordpress.org/Child_Themes), you can override certain
  11. * functions (those wrapped in a function_exists() call) by defining them first
  12. * in your child theme's functions.php file. The child theme's functions.php
  13. * file is included before the parent theme's file, so the child theme
  14. * functions would be used.
  15. *
  16. * Functions that are not pluggable (not wrapped in function_exists()) are
  17. * instead attached to a filter or action hook.
  18. *
  19. * For more information on hooks, actions, and filters, @link https://codex.wordpress.org/Plugin_API
  20. *
  21. * @package WordPress
  22. * @subpackage Twenty_Thirteen
  23. * @since Twenty Thirteen 1.0
  24. */
  25. /*
  26. * Set up the content width value based on the theme's design.
  27. *
  28. * @see twentythirteen_content_width() for template-specific adjustments.
  29. */
  30. if ( ! isset( $content_width ) )
  31. $content_width = 604;
  32. /**
  33. * Add support for a custom header image.
  34. */
  35. require get_template_directory() . '/inc/custom-header.php';
  36. /**
  37. * Twenty Thirteen only works in WordPress 3.6 or later.
  38. */
  39. if ( version_compare( $GLOBALS['wp_version'], '3.6-alpha', '<' ) )
  40. require get_template_directory() . '/inc/back-compat.php';
  41. /**
  42. * Twenty Thirteen setup.
  43. *
  44. * Sets up theme defaults and registers the various WordPress features that
  45. * Twenty Thirteen supports.
  46. *
  47. * @uses load_theme_textdomain() For translation/localization support.
  48. * @uses add_editor_style() To add Visual Editor stylesheets.
  49. * @uses add_theme_support() To add support for automatic feed links, post
  50. * formats, and post thumbnails.
  51. * @uses register_nav_menu() To add support for a navigation menu.
  52. * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  53. *
  54. * @since Twenty Thirteen 1.0
  55. */
  56. function twentythirteen_setup() {
  57. /*
  58. * Makes Twenty Thirteen available for translation.
  59. *
  60. * Translations can be added to the /languages/ directory.
  61. * If you're building a theme based on Twenty Thirteen, use a find and
  62. * replace to change 'twentythirteen' to the name of your theme in all
  63. * template files.
  64. */
  65. load_theme_textdomain( 'twentythirteen', get_template_directory() . '/languages' );
  66. /*
  67. * This theme styles the visual editor to resemble the theme style,
  68. * specifically font, colors, icons, and column width.
  69. */
  70. add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css', twentythirteen_fonts_url() ) );
  71. // Adds RSS feed links to <head> for posts and comments.
  72. add_theme_support( 'automatic-feed-links' );
  73. /*
  74. * Switches default core markup for search form, comment form,
  75. * and comments to output valid HTML5.
  76. */
  77. add_theme_support( 'html5', array(
  78. 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
  79. ) );
  80. /*
  81. * This theme supports all available post formats by default.
  82. * See https://codex.wordpress.org/Post_Formats
  83. */
  84. add_theme_support( 'post-formats', array(
  85. 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video'
  86. ) );
  87. // This theme uses wp_nav_menu() in one location.
  88. register_nav_menu( 'primary', __( 'Navigation Menu', 'twentythirteen' ) );
  89. /*
  90. * This theme uses a custom image size for featured images, displayed on
  91. * "standard" posts and pages.
  92. */
  93. add_theme_support( 'post-thumbnails' );
  94. set_post_thumbnail_size( 604, 270, true );
  95. // This theme uses its own gallery styles.
  96. add_filter( 'use_default_gallery_style', '__return_false' );
  97. }
  98. add_action( 'after_setup_theme', 'twentythirteen_setup' );
  99. /**
  100. * Return the Google font stylesheet URL, if available.
  101. *
  102. * The use of Source Sans Pro and Bitter by default is localized. For languages
  103. * that use characters not supported by the font, the font can be disabled.
  104. *
  105. * @since Twenty Thirteen 1.0
  106. *
  107. * @return string Font stylesheet or empty string if disabled.
  108. */
  109. function twentythirteen_fonts_url() {
  110. $fonts_url = '';
  111. /* Translators: If there are characters in your language that are not
  112. * supported by Source Sans Pro, translate this to 'off'. Do not translate
  113. * into your own language.
  114. */
  115. $source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'twentythirteen' );
  116. /* Translators: If there are characters in your language that are not
  117. * supported by Bitter, translate this to 'off'. Do not translate into your
  118. * own language.
  119. */
  120. $bitter = _x( 'on', 'Bitter font: on or off', 'twentythirteen' );
  121. if ( 'off' !== $source_sans_pro || 'off' !== $bitter ) {
  122. $font_families = array();
  123. if ( 'off' !== $source_sans_pro )
  124. $font_families[] = 'Source Sans Pro:300,400,700,300italic,400italic,700italic';
  125. if ( 'off' !== $bitter )
  126. $font_families[] = 'Bitter:400,700';
  127. $query_args = array(
  128. 'family' => urlencode( implode( '|', $font_families ) ),
  129. 'subset' => urlencode( 'latin,latin-ext' ),
  130. );
  131. //$fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
  132. }
  133. return $fonts_url;
  134. }
  135. /**
  136. * Enqueue scripts and styles for the front end.
  137. *
  138. * @since Twenty Thirteen 1.0
  139. */
  140. add_image_size( 'medium-something', 480, 480 );
  141. add_image_size( 'my-thumbnail', 400, 1200, true);
  142. function twentythirteen_scripts_styles() {
  143. /*
  144. * Adds JavaScript to pages with the comment form to support
  145. * sites with threaded comments (when in use).
  146. */
  147. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
  148. wp_enqueue_script( 'comment-reply' );
  149. // Adds Masonry to handle vertical alignment of footer widgets.
  150. if ( is_active_sidebar( 'sidebar-1' ) )
  151. wp_enqueue_script( 'jquery-masonry' );
  152. // Loads JavaScript file with functionality specific to Twenty Thirteen.
  153. wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150330', true );
  154. // Add Source Sans Pro and Bitter fonts, used in the main stylesheet.
  155. wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null );
  156. // Add Genericons font, used in the main stylesheet.
  157. wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.03' );
  158. // Loads our main stylesheet.
  159. wp_enqueue_style( 'twentythirteen-style', get_stylesheet_uri(), array(), '2013-07-18' );
  160. // Loads the Internet Explorer specific stylesheet.
  161. wp_enqueue_style( 'twentythirteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentythirteen-style' ), '2013-07-18' );
  162. wp_style_add_data( 'twentythirteen-ie', 'conditional', 'lt IE 9' );
  163. }
  164. add_action( 'wp_enqueue_scripts', 'twentythirteen_scripts_styles' );
  165. /**
  166. * Filter the page title.
  167. *
  168. * Creates a nicely formatted and more specific title element text for output
  169. * in head of document, based on current view.
  170. *
  171. * @since Twenty Thirteen 1.0
  172. *
  173. * @param string $title Default title text for current view.
  174. * @param string $sep Optional separator.
  175. * @return string The filtered title.
  176. */
  177. function twentythirteen_wp_title( $title, $sep ) {
  178. global $paged, $page;
  179. if ( is_feed() )
  180. return $title;
  181. // Add the site name.
  182. $title .= get_bloginfo( 'name', 'display' );
  183. // Add the site description for the home/front page.
  184. $site_description = get_bloginfo( 'description', 'display' );
  185. if ( $site_description && ( is_home() || is_front_page() ) )
  186. $title = "$title $sep $site_description";
  187. // Add a page number if necessary.
  188. if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() )
  189. $title = "$title $sep " . sprintf( __( 'Page %s', 'twentythirteen' ), max( $paged, $page ) );
  190. return $title;
  191. }
  192. add_filter( 'wp_title', 'twentythirteen_wp_title', 10, 2 );
  193. /**
  194. * Register two widget areas.
  195. *
  196. * @since Twenty Thirteen 1.0
  197. */
  198. function twentythirteen_widgets_init() {
  199. register_sidebar( array(
  200. 'name' => __( 'Main Widget Area', 'twentythirteen' ),
  201. 'id' => 'sidebar-1',
  202. 'description' => __( 'Appears in the footer section of the site.', 'twentythirteen' ),
  203. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  204. 'after_widget' => '</aside>',
  205. 'before_title' => '<h3 class="widget-title">',
  206. 'after_title' => '</h3>',
  207. ) );
  208. register_sidebar( array(
  209. 'name' => __( 'Secondary Widget Area', 'twentythirteen' ),
  210. 'id' => 'sidebar-2',
  211. 'description' => __( 'Appears on posts and pages in the sidebar.', 'twentythirteen' ),
  212. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  213. 'after_widget' => '</aside>',
  214. 'before_title' => '<h3 class="widget-title">',
  215. 'after_title' => '</h3>',
  216. ) );
  217. register_sidebar( array(
  218. 'name' => __( 'Mobile Menu', 'twentythirteen' ),
  219. 'id' => 'sidebar-3',
  220. 'description' => __( 'Appears on mobile.', 'twentythirteen' ),
  221. 'before_widget' => '<div class="mr-mobile-menu-out">',
  222. 'after_widget' => '</div>',
  223. 'before_title' => '<h3 class="widget-title">',
  224. 'after_title' => '</h3>',
  225. ) );
  226. }
  227. add_action( 'widgets_init', 'twentythirteen_widgets_init' );
  228. if ( ! function_exists( 'twentythirteen_paging_nav' ) ) :
  229. /**
  230. * Display navigation to next/previous set of posts when applicable.
  231. *
  232. * @since Twenty Thirteen 1.0
  233. */
  234. function twentythirteen_paging_nav() {
  235. global $wp_query;
  236. // Don't print empty markup if there's only one page.
  237. if ( $wp_query->max_num_pages < 2 )
  238. return;
  239. ?>
  240. <nav class="navigation paging-navigation" role="navigation">
  241. <h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentythirteen' ); ?></h1>
  242. <div class="nav-links">
  243. <?php if ( get_next_posts_link() ) : ?>
  244. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentythirteen' ) ); ?></div>
  245. <?php endif; ?>
  246. <?php if ( get_previous_posts_link() ) : ?>
  247. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentythirteen' ) ); ?></div>
  248. <?php endif; ?>
  249. </div><!-- .nav-links -->
  250. </nav><!-- .navigation -->
  251. <?php
  252. }
  253. endif;
  254. if ( ! function_exists( 'twentythirteen_post_nav' ) ) :
  255. /**
  256. * Display navigation to next/previous post when applicable.
  257. *
  258. * @since Twenty Thirteen 1.0
  259. */
  260. function twentythirteen_post_nav() {
  261. global $post;
  262. // Don't print empty markup if there's nowhere to navigate.
  263. $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
  264. $next = get_adjacent_post( false, '', false );
  265. if ( ! $next && ! $previous )
  266. return;
  267. ?>
  268. <nav class="navigation post-navigation" role="navigation">
  269. <h1 class="screen-reader-text"><?php _e( 'Post navigation', 'twentythirteen' ); ?></h1>
  270. <div class="nav-links">
  271. <?php previous_post_link( '%link', _x( '<span class="meta-nav">&larr;</span> %title', 'Previous post link', 'twentythirteen' ) ); ?>
  272. <?php next_post_link( '%link', _x( '%title <span class="meta-nav">&rarr;</span>', 'Next post link', 'twentythirteen' ) ); ?>
  273. </div><!-- .nav-links -->
  274. </nav><!-- .navigation -->
  275. <?php
  276. }
  277. endif;
  278. if ( ! function_exists( 'twentythirteen_entry_meta' ) ) :
  279. /**
  280. * Print HTML with meta information for current post: categories, tags, permalink, author, and date.
  281. *
  282. * Create your own twentythirteen_entry_meta() to override in a child theme.
  283. *
  284. * @since Twenty Thirteen 1.0
  285. */
  286. function twentythirteen_entry_meta() {
  287. if ( is_sticky() && is_home() && ! is_paged() )
  288. echo '<span class="featured-post">' . esc_html__( 'Sticky', 'twentythirteen' ) . '</span>';
  289. if ( ! has_post_format( 'link' ) && 'post' == get_post_type() )
  290. twentythirteen_entry_date();
  291. // Translators: used between list items, there is a space after the comma.
  292. $categories_list = get_the_category_list( __( ', ', 'twentythirteen' ) );
  293. if ( $categories_list ) {
  294. echo '<span class="categories-links">' . $categories_list . '</span>';
  295. }
  296. // Translators: used between list items, there is a space after the comma.
  297. $tag_list = get_the_tag_list( '', __( ', ', 'twentythirteen' ) );
  298. if ( $tag_list ) {
  299. echo '<span class="tags-links">' . $tag_list . '</span>';
  300. }
  301. // Post author
  302. if ( 'post' == get_post_type() ) {
  303. printf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
  304. esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
  305. esc_attr( sprintf( __( 'View all posts by %s', 'twentythirteen' ), get_the_author() ) ),
  306. get_the_author()
  307. );
  308. }
  309. }
  310. endif;
  311. if ( ! function_exists( 'twentythirteen_entry_date' ) ) :
  312. /**
  313. * Print HTML with date information for current post.
  314. *
  315. * Create your own twentythirteen_entry_date() to override in a child theme.
  316. *
  317. * @since Twenty Thirteen 1.0
  318. *
  319. * @param boolean $echo (optional) Whether to echo the date. Default true.
  320. * @return string The HTML-formatted post date.
  321. */
  322. function twentythirteen_entry_date( $echo = true ) {
  323. if ( has_post_format( array( 'chat', 'status' ) ) )
  324. $format_prefix = _x( '%1$s on %2$s', '1: post format name. 2: date', 'twentythirteen' );
  325. else
  326. $format_prefix = '%2$s';
  327. $date = sprintf( '<span class="date"><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a></span>',
  328. esc_url( get_permalink() ),
  329. esc_attr( sprintf( __( 'Permalink to %s', 'twentythirteen' ), the_title_attribute( 'echo=0' ) ) ),
  330. esc_attr( get_the_date( 'c' ) ),
  331. esc_html( sprintf( $format_prefix, get_post_format_string( get_post_format() ), get_the_date() ) )
  332. );
  333. if ( $echo )
  334. echo $date;
  335. return $date;
  336. }
  337. endif;
  338. if ( ! function_exists( 'twentythirteen_the_attached_image' ) ) :
  339. /**
  340. * Print the attached image with a link to the next attached image.
  341. *
  342. * @since Twenty Thirteen 1.0
  343. */
  344. function twentythirteen_the_attached_image() {
  345. /**
  346. * Filter the image attachment size to use.
  347. *
  348. * @since Twenty thirteen 1.0
  349. *
  350. * @param array $size {
  351. * @type int The attachment height in pixels.
  352. * @type int The attachment width in pixels.
  353. * }
  354. */
  355. $attachment_size = apply_filters( 'twentythirteen_attachment_size', array( 724, 724 ) );
  356. $next_attachment_url = wp_get_attachment_url();
  357. $post = get_post();
  358. /*
  359. * Grab the IDs of all the image attachments in a gallery so we can get the URL
  360. * of the next adjacent image in a gallery, or the first image (if we're
  361. * looking at the last image in a gallery), or, in a gallery of one, just the
  362. * link to that image file.
  363. */
  364. $attachment_ids = get_posts( array(
  365. 'post_parent' => $post->post_parent,
  366. 'fields' => 'ids',
  367. 'numberposts' => -1,
  368. 'post_status' => 'inherit',
  369. 'post_type' => 'attachment',
  370. 'post_mime_type' => 'image',
  371. 'order' => 'ASC',
  372. 'orderby' => 'menu_order ID',
  373. ) );
  374. // If there is more than 1 attachment in a gallery...
  375. if ( count( $attachment_ids ) > 1 ) {
  376. foreach ( $attachment_ids as $attachment_id ) {
  377. if ( $attachment_id == $post->ID ) {
  378. $next_id = current( $attachment_ids );
  379. break;
  380. }
  381. }
  382. // get the URL of the next image attachment...
  383. if ( $next_id )
  384. $next_attachment_url = get_attachment_link( $next_id );
  385. // or get the URL of the first image attachment.
  386. else
  387. $next_attachment_url = get_attachment_link( reset( $attachment_ids ) );
  388. }
  389. printf( '<a href="%1$s" title="%2$s" rel="attachment">%3$s</a>',
  390. esc_url( $next_attachment_url ),
  391. the_title_attribute( array( 'echo' => false ) ),
  392. wp_get_attachment_image( $post->ID, $attachment_size )
  393. );
  394. }
  395. endif;
  396. /**
  397. * Return the post URL.
  398. *
  399. * @uses get_url_in_content() to get the URL in the post meta (if it exists) or
  400. * the first link found in the post content.
  401. *
  402. * Falls back to the post permalink if no URL is found in the post.
  403. *
  404. * @since Twenty Thirteen 1.0
  405. *
  406. * @return string The Link format URL.
  407. */
  408. function twentythirteen_get_link_url() {
  409. $content = get_the_content();
  410. $has_url = get_url_in_content( $content );
  411. return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
  412. }
  413. if ( ! function_exists( 'twentythirteen_excerpt_more' ) && ! is_admin() ) :
  414. /**
  415. * Replaces "[...]" (appended to automatically generated excerpts) with ...
  416. * and a Continue reading link.
  417. *
  418. * @since Twenty Thirteen 1.4
  419. *
  420. * @param string $more Default Read More excerpt link.
  421. * @return string Filtered Read More excerpt link.
  422. */
  423. function twentythirteen_excerpt_more( $more ) {
  424. $link = sprintf( '<a href="%1$s" class="more-link">%2$s</a>',
  425. esc_url( get_permalink( get_the_ID() ) ),
  426. /* translators: %s: Name of current post */
  427. sprintf( __( 'Continue reading %s <span class="meta-nav">&rarr;</span>', 'twentythirteen' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' )
  428. );
  429. return ' &hellip; ' . $link;
  430. }
  431. add_filter( 'excerpt_more', 'twentythirteen_excerpt_more' );
  432. endif;
  433. /**
  434. * Extend the default WordPress body classes.
  435. *
  436. * Adds body classes to denote:
  437. * 1. Single or multiple authors.
  438. * 2. Active widgets in the sidebar to change the layout and spacing.
  439. * 3. When avatars are disabled in discussion settings.
  440. *
  441. * @since Twenty Thirteen 1.0
  442. *
  443. * @param array $classes A list of existing body class values.
  444. * @return array The filtered body class list.
  445. */
  446. function twentythirteen_body_class( $classes ) {
  447. if ( ! is_multi_author() )
  448. $classes[] = 'single-author';
  449. if ( is_active_sidebar( 'sidebar-2' ) && ! is_attachment() && ! is_404() )
  450. $classes[] = 'sidebar';
  451. if ( ! get_option( 'show_avatars' ) )
  452. $classes[] = 'no-avatars';
  453. return $classes;
  454. }
  455. add_filter( 'body_class', 'twentythirteen_body_class' );
  456. /**
  457. * Adjust content_width value for video post formats and attachment templates.
  458. *
  459. * @since Twenty Thirteen 1.0
  460. */
  461. function twentythirteen_content_width() {
  462. global $content_width;
  463. if ( is_attachment() )
  464. $content_width = 724;
  465. elseif ( has_post_format( 'audio' ) )
  466. $content_width = 484;
  467. }
  468. add_action( 'template_redirect', 'twentythirteen_content_width' );
  469. /**
  470. * Add postMessage support for site title and description for the Customizer.
  471. *
  472. * @since Twenty Thirteen 1.0
  473. *
  474. * @param WP_Customize_Manager $wp_customize Customizer object.
  475. */
  476. function twentythirteen_customize_register( $wp_customize ) {
  477. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
  478. $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
  479. $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
  480. }
  481. add_action( 'customize_register', 'twentythirteen_customize_register' );
  482. /**
  483. * Enqueue Javascript postMessage handlers for the Customizer.
  484. *
  485. * Binds JavaScript handlers to make the Customizer preview
  486. * reload changes asynchronously.
  487. *
  488. * @since Twenty Thirteen 1.0
  489. */
  490. function twentythirteen_customize_preview_js() {
  491. wp_enqueue_script( 'twentythirteen-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20141120', true );
  492. }
  493. add_action( 'customize_preview_init', 'twentythirteen_customize_preview_js' );
  494. function themeslug_theme_customizer( $wp_customize ) {
  495. // Fun code will go here
  496. $wp_customize->add_section( 'themeslug_logo_section' , array(
  497. 'title' => __( 'Logo', 'themeslug' ),
  498. 'priority' => 30,
  499. 'description' => 'Upload a logo to replace the default site name and description in the header',
  500. ) );
  501. $wp_customize->add_setting( 'themeslug_logo' );
  502. $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'themeslug_logo', array(
  503. 'label' => __( 'Logo', 'themeslug' ),
  504. 'section' => 'themeslug_logo_section',
  505. 'settings' => 'themeslug_logo',
  506. ) ) );
  507. }
  508. add_action( 'customize_register', 'themeslug_theme_customizer' );
  509. //get number view
  510. /*function setPostViews($postID) {
  511. $count_key = 'post_views_count';
  512. $count = get_post_meta($postID, $count_key, true);
  513. if($count==''){
  514. $count = 0;
  515. delete_post_meta($postID, $count_key);
  516. add_post_meta($postID, $count_key, '0');
  517. }else{
  518. $count++;
  519. update_post_meta($postID, $count_key, $count);
  520. }
  521. }*/
  522. function getPostViews($postID){
  523. $count_key = 'post_views_count';
  524. $count = get_post_meta($postID, $count_key, true);
  525. if($count==''){
  526. delete_post_meta($postID, $count_key);
  527. add_post_meta($postID, $count_key, '0');
  528. return "0";
  529. }
  530. return $count.'';
  531. }
  532. // function to count views.
  533. function setPostViews($postID) {
  534. $count_key = 'post_views_count';
  535. $count = get_post_meta($postID, $count_key, true);
  536. if($count==''){
  537. $count = 0;
  538. delete_post_meta($postID, $count_key);
  539. add_post_meta($postID, $count_key, '0');
  540. }else{
  541. $count++;
  542. update_post_meta($postID, $count_key, $count);
  543. }
  544. }
  545. // Remove issues with prefetching adding extra views
  546. remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
  547. /* ################# Register Exclusive Galleries ############################ */
  548. function register_cutompost_model() {
  549. $labels = array(
  550. 'name' =>'Models',
  551. 'singular_name' =>'Model',
  552. 'menu_name' =>'Models',
  553. 'name_admin_bar' =>'Models',
  554. 'add_new' =>'Add New',
  555. 'add_new_item' =>'Add New Model',
  556. 'new_item' =>'New Model',
  557. 'edit_item' =>'Edit Model',
  558. 'view_item' =>'View Model',
  559. 'all_items' =>'All Model',
  560. 'search_items' =>'Search Model',
  561. 'parent_item_colon' =>'Parent Model',
  562. 'not_found' =>'No Models found.',
  563. 'not_found_in_trash' =>'No Models found in Trash.'
  564. );
  565. $args = array(
  566. 'labels' => $labels,
  567. 'description' =>'Description.',
  568. 'public' => true,
  569. 'publicly_queryable' => true,
  570. 'show_ui' => true,
  571. 'show_in_menu' => true,
  572. 'query_var' => true,
  573. 'rewrite' => array( 'slug' => 'bornstar', 'with_front' => FALSE ),
  574. 'capability_type' => 'post',
  575. 'has_archive' => true,
  576. 'hierarchical' => false,
  577. 'menu_position' =>8,
  578. 'supports' => array( 'title','thumbnail','editor','comments')
  579. );
  580. register_post_type( 'model', $args );
  581. }
  582. add_action( 'init', 'register_cutompost_model');
  583. function register_cutompost_freeGallery() {
  584. $labels = array(
  585. 'name' =>'Free Gallery',
  586. 'singular_name' =>'Free Gallery',
  587. 'menu_name' =>'Free Galleries',
  588. 'name_admin_bar' =>'Free Galleries',
  589. 'add_new' =>'Add New',
  590. 'add_new_item' =>'Add New Free gallery',
  591. 'new_item' =>'New Free gallery',
  592. 'edit_item' =>'Edit Free gallery',
  593. 'view_item' =>'View Free gallery',
  594. 'all_items' =>'All Free gallery',
  595. 'search_items' =>'Search Free gallery',
  596. 'parent_item_colon' =>'Parent Free gallery:',
  597. 'not_found' =>'No Free Galleries found.',
  598. 'not_found_in_trash' =>'No Free Galleries found in Trash.'
  599. );
  600. $args = array(
  601. 'labels' => $labels,
  602. 'description' =>'Description.',
  603. 'public' => true,
  604. 'publicly_queryable' => true,
  605. 'show_ui' => true,
  606. 'show_in_menu' => true,
  607. 'query_var' => true,
  608. 'rewrite' => array( 'slug' => 'gallery', 'with_front' => FALSE ),
  609. 'capability_type' => 'post',
  610. 'has_archive' => true,
  611. 'hierarchical' => false,
  612. 'menu_position' =>5,
  613. 'supports' => array( 'title','thumbnail','editor','comments')
  614. );
  615. register_post_type( 'freeGallery', $args );
  616. $labels1 = array(
  617. 'name' =>'Free Videos',
  618. 'singular_name' =>'Free Video',
  619. 'menu_name' =>'Free Videos',
  620. 'name_admin_bar' =>'Free Videos',
  621. 'add_new' =>'Add New',
  622. 'add_new_item' =>'Add New Free Video',
  623. 'new_item' =>'New Free Video',
  624. 'edit_item' =>'Edit Free Video',
  625. 'view_item' =>'View Free Video',
  626. 'all_items' =>'All Free Video',
  627. 'search_items' =>'Search Free Video',
  628. 'parent_item_colon' =>'Parent Free Video:',
  629. 'not_found' =>'No Free Videos found.',
  630. 'not_found_in_trash' =>'No Free Videos found in Trash.'
  631. );
  632. $args1 = array(
  633. 'labels' => $labels1,
  634. 'description' =>'Description.',
  635. 'public' => true,
  636. 'publicly_queryable' => true,
  637. 'show_ui' => true,
  638. 'show_in_menu' => true,
  639. 'query_var' => true,
  640. 'rewrite' => array( 'slug' => 'video','with_front' => FALSE ),
  641. 'capability_type' => 'post',
  642. 'has_archive' => true,
  643. 'hierarchical' => false,
  644. 'menu_position' =>6,
  645. 'supports' => array( 'title','thumbnail','editor','custom-fields','post-formats','comments' )
  646. );
  647. register_post_type( 'freeVideo', $args1 );
  648. /* #################### Register For Article ############### */
  649. $labels2 = array(
  650. 'name' =>'Blogs',
  651. 'singular_name' =>'Site',
  652. 'menu_name' =>'Blogs',
  653. 'name_admin_bar' =>'Blogs',
  654. 'add_new' =>'Add New',
  655. 'add_new_item' =>'Add New Blog',
  656. 'new_item' =>'New Blog',
  657. 'edit_item' =>'Edit Blog',
  658. 'view_item' =>'View Blog',
  659. 'all_items' =>'All Blog',
  660. 'search_items' =>'Search Site',
  661. 'parent_item_colon' =>'Parent Site:',
  662. 'not_found' =>'No Free Sites found.',
  663. 'not_found_in_trash' =>'No Free Sites found in Trash.'
  664. );
  665. $args2 = array(
  666. 'labels' => $labels2,
  667. 'description' =>'Description.',
  668. 'public' => true,
  669. 'publicly_queryable' => true,
  670. 'show_ui' => true,
  671. 'show_in_menu' => true,
  672. 'query_var' => true,
  673. 'rewrite' => array( 'slug' => 'article' ),
  674. 'capability_type' => 'post',
  675. 'has_archive' => true,
  676. 'hierarchical' => false,
  677. 'menu_position' =>7,
  678. 'supports' => array( 'title','thumbnail','editor','excerpt','comments')
  679. );
  680. register_post_type( 'blog',$args2);
  681. /* End code of Articles */
  682. /* #################### Register For Sites ############### */
  683. $labels3 = array(
  684. 'name' =>'Sites',
  685. 'singular_name' =>'Site',
  686. 'menu_name' =>'Sites',
  687. 'name_admin_bar' =>'Sites',
  688. 'add_new' =>'Add New',
  689. 'add_new_item' =>'Add New Site',
  690. 'new_item' =>'New Site',
  691. 'edit_item' =>'Edit Site',
  692. 'view_item' =>'View Site',
  693. 'all_items' =>'All Site',
  694. 'search_items' =>'Search Site',
  695. 'parent_item_colon' =>'Parent Site:',
  696. 'not_found' =>'No Free Sites found.',
  697. 'not_found_in_trash' =>'No Free Sites found in Trash.'
  698. );
  699. $args3 = array(
  700. 'labels' => $labels3,
  701. 'description' =>'Description.',
  702. 'public' => true,
  703. 'publicly_queryable' => true,
  704. 'show_ui' => true,
  705. 'show_in_menu' => true,
  706. 'query_var' => true,
  707. 'rewrite' => array( 'slug' => 'site' ),
  708. 'capability_type' => 'post',
  709. 'has_archive' => true,
  710. 'hierarchical' => false,
  711. 'menu_position' =>7,
  712. 'supports' => array( 'title','thumbnail','editor','comments')
  713. );
  714. register_post_type( 'mrsite',$args3);
  715. /* End code of Sites */
  716. }
  717. add_action( 'init', 'register_cutompost_freeGallery' );
  718. /* ################# Add Area for Free Gallery #######################*/
  719. add_action( 'add_meta_boxes', 'mr_free_galleries_area' );
  720. function mr_free_galleries_area()
  721. {
  722. /* add_meta_box('mr-free-gallery-section','Free Galleries Box','mr_free_galleryBox_callback','post'); */
  723. /* add_meta_box('mr-free-video-section','Free Videos Box','mr_free_videoBox_callback','post'); */
  724. add_meta_box('mr-discount-section','Discount Box','discount_price_fields','post');
  725. add_meta_box('mr-price-section','Price Box','price_table_fields','post');
  726. add_meta_box('mr-feature-section','Feature Box','feature_box_fields','post');
  727. add_meta_box('mr-random-post-section','Random Post And Feaure Video','randon_post','post');
  728. add_meta_box('mr-extra_tag-section','Custom Tag Fields','custom_tag_fields','post');
  729. add_meta_box('mr-magnifying_glass-section','Magnifying Glass','magnifying_glass','post');
  730. add_meta_box('mr-post-extra-section','Fields For Texr','post_extra_desc','post');
  731. add_meta_box('mr-dicounted-extra-section','Select Extra Discounted Sites Box','discount_extra_sites','post');
  732. /* Function that allow links to sites */
  733. add_meta_box('mr-model-siteopt','Model Appear in sites','mr_modelsites_sectionfun','model'); // For single model
  734. add_meta_box('mr-data-siteopt','Site Data Section','mr_sites_sectionfun','mrsite'); // For single model
  735. add_meta_box('mr-more-born-sites','Born Sites','more_born_sites','post', 'normal', 'high');
  736. add_meta_box('mr-FreeGallery-data','Gallery Data Section','mr_gallerydata_sectionfun','freegallery'); // For single gallery
  737. add_meta_box('mr-videosingle-data','Video Data Section','mr_video_data_sectionfun','freevideo'); // for single video
  738. add_meta_box('pr-detailss-section','Today offer','today_offer','post', 'normal', 'high');
  739. }
  740. /* Function For site data */
  741. function mr_sites_sectionfun($site_data)
  742. {
  743. ?>
  744. <table width="80%">
  745. <tr>
  746. <td width="110px">Enter Site Url</td>
  747. <td><input style="width:100%;" value="<?php echo get_post_meta($site_data->ID,"mr_siteCustomUrl",true); ?>" type="text" name="mr_siteCustomUrl" /></td>
  748. </tr>
  749. </table>
  750. <?php
  751. }
  752. /* //For model site opt */
  753. function mr_modelsites_sectionfun($model_data)
  754. {
  755. $model_id = $model_data->ID;
  756. $argsSites = array('post_type' =>'post','post_status'=>'publish','posts_per_page'=>-1);
  757. $my_sitequery = null;
  758. $my_sitequery = new WP_Query($argsSites);
  759. if($my_sitequery->have_posts())
  760. {
  761. ?>
  762. <style type="text/css">
  763. .listof-allsites-out li
  764. {
  765. background: #f5f5f5 none repeat scroll 0 0; border-radius:3px; float: left;
  766. margin-bottom: 10px;margin-left: 2px;margin-right: 2px; padding: 5px 8px;width: 22.5%;
  767. }
  768. .listof-allsites-out > ul {list-style: outside none none;margin:10px 0px;padding: 0;}
  769. .site-frm-submit-out { border-top: 2px solid #ddd; padding: 5px 2px; text-align: right;}
  770. .listof-allsites-out li:hover {background: #ddd none repeat scroll 0 0;}
  771. </style>
  772. <div class="listof-allsites-out">
  773. <?php
  774. $model_sitesId = get_post_meta($model_id,"mr_model_appear_sites",true);
  775. $model_sitesArr = explode(",",$model_sitesId) ;
  776. ?>
  777. <ul>
  778. <?php
  779. while($my_sitequery->have_posts()) : $my_sitequery->the_post();
  780. $site_id = get_the_ID();
  781. if(in_array($site_id,$model_sitesArr))
  782. {
  783. $mr_ckbstatus = 'checked="checked"';
  784. }
  785. else
  786. {
  787. $mr_ckbstatus='';
  788. }
  789. ?>
  790. <li>
  791. <input type="checkbox" name="mr_modelSite[]" <?php echo $mr_ckbstatus; ?> value="<?php echo $site_id; ?>" />
  792. <p style="display:inline;"> <?php echo get_the_title(); ?></p>
  793. </li>
  794. <?php
  795. endwhile;
  796. ?>
  797. <div style="clear:both;"></div>
  798. </ul>
  799. <div style="clear:both;"></div>
  800. </div>
  801. <?php
  802. wp_reset_query();
  803. }
  804. else
  805. {
  806. ?>
  807. <div class="error-mess"><h2 style="text-align:center; color:red;">No Sites</h2></div>
  808. <?php
  809. }
  810. }
  811. add_action('save_post', 'save_gallery_data');
  812. function save_gallery_data(){
  813. global $post;
  814. /* ########################################## Save Post model & site Data ################### */
  815. if(($post->post_type == 'post')&&(isset($_POST['mr_active_discount']))){
  816. update_post_meta($post->ID, 'mr_active_discount', $_POST['mr_active_discount']);
  817. $random_v =$_POST['mr_random_post'];
  818. if($random_v==''){
  819. update_post_meta($post->ID, 'mr_random_post', 'empty');
  820. }
  821. else{
  822. update_post_meta($post->ID, 'mr_random_post', $_POST['mr_random_post']);
  823. }
  824. update_post_meta($post->ID, 'mr_feature_video', $_POST['mr_feature_video']);
  825. update_post_meta($post->ID, 'catag', $_POST['catag']);
  826. update_post_meta($post->ID, 'domaintag', $_POST['domaintag']);
  827. update_post_meta($post->ID, 'post_external_link', $_POST['post_external_link']);
  828. update_post_meta($post->ID, 'joink_external_link', $_POST['joink_external_link']);
  829. update_post_meta($post->ID, 'titletag', $_POST['titletag']);
  830. update_post_meta($post->ID, 'mr_magnifying_glass', $_POST['mr_magnifying_glass']);
  831. update_post_meta($post->ID, 'mr_topdeal_discount', $_POST['mr_topdeal_discount']);
  832. update_post_meta($post->ID, 'mr_new_discount', $_POST['mr_new_discount']);
  833. update_post_meta($post->ID, 'mr_lifetime_discount', $_POST['mr_lifetime_discount']);
  834. update_post_meta($post->ID, 'mr_regularprice', $_POST['mr_regularprice']);
  835. update_post_meta($post->ID, 'mr_saleprice', $_POST['mr_saleprice']);
  836. update_post_meta($post->ID, 'mr_discountprice', $_POST['mr_discountprice']);
  837. update_post_meta($post->ID, 'mr_discount_des', $_POST['mr_discount_des']);
  838. update_post_meta($post->ID, 'mr_discount_Image', $_POST['mr_discount_Image']);
  839. update_post_meta($post->ID, 'mr_month_price', $_POST['mr_month_price']);
  840. @update_post_meta($post->ID, 'discount-extra-site', array_map( 'strip_tags', $_POST['discount-extra-site'] ) );
  841. update_post_meta($post->ID, 'mr_month_off', $_POST['mr_month_off']);
  842. update_post_meta($post->ID, 'mr_month_lastrice', $_POST['mr_month_lastrice']);
  843. update_post_meta($post->ID, 'mr_sixmonth_price', $_POST['mr_sixmonth_price']);
  844. update_post_meta($post->ID, 'mr_sixmonth_off', $_POST['mr_sixmonth_off']);
  845. update_post_meta($post->ID, 'mr_sixmonth_lastrice', $_POST['mr_sixmonth_lastrice']);
  846. update_post_meta($post->ID, 'mr_per_month3', $_POST['mr_per_month3']);
  847. update_post_meta($post->ID, 'mr_threeyear_price', $_POST['mr_threeyear_price']);
  848. update_post_meta($post->ID, 'mr_threeyear_off', $_POST['mr_threeyear_off']);
  849. update_post_meta($post->ID, 'mr_threeyear_lastrice', $_POST['mr_threeyear_lastrice']);
  850. update_post_meta($post->ID, 'mr_per_month6', $_POST['mr_per_month6']);
  851. update_post_meta($post->ID, 'mr_fiveyear_price', $_POST['mr_fiveyear_price']);
  852. update_post_meta($post->ID, 'mr_fiveyear_off', $_POST['mr_fiveyear_off']);
  853. update_post_meta($post->ID, 'mr_fiveyear_lastrice', $_POST['mr_fiveyear_lastrice']);
  854. update_post_meta($post->ID, 'mr_per_month12', $_POST['mr_per_month12']);
  855. update_post_meta($post->ID, 'mr_feature1', $_POST['mr_feature1']);
  856. update_post_meta($post->ID, 'mr_feature2', $_POST['mr_feature2']);
  857. update_post_meta($post->ID, 'mr_feature3', $_POST['mr_feature3']);
  858. update_post_meta($post->ID, 'mr_feature4', $_POST['mr_feature4']);
  859. update_post_meta($post->ID, 'mr_feature5', $_POST['mr_feature5']);
  860. update_post_meta($post->ID, 'mr_feature6', $_POST['mr_feature6']);
  861. update_post_meta($post->ID, 'mr_feature1_Image', $_POST['mr_feature1_Image']);
  862. update_post_meta($post->ID, 'mr_feature2_Image', $_POST['mr_feature2_Image']);
  863. update_post_meta($post->ID, 'mr_feature3_Image', $_POST['mr_feature3_Image']);
  864. update_post_meta($post->ID, 'mr_feature4_Image', $_POST['mr_feature4_Image']);
  865. update_post_meta($post->ID, 'mr_feature5_Image', $_POST['mr_feature5_Image']);
  866. update_post_meta($post->ID, 'mr_discount_des', $_POST['mr_discount_des']);
  867. update_post_meta($post->ID, 'mr_discount_Image', $_POST['mr_discount_Image']);
  868. update_post_meta($post->ID, 'mr_discountbutton_url', $_POST['mr_discountbutton_url']);
  869. update_post_meta($post->ID, 'mr_quility_des', $_POST['mr_quility_des']);
  870. update_post_meta($post->ID, 'mr_content_des', $_POST['mr_content_des']);
  871. /* update_post_meta($post->ID, 'mr_pros_des', $_POST['mr_pros_des']); */
  872. /* update_post_meta($post->ID, 'mr_cons_des', $_POST['mr_cons_des']); */
  873. /* update_post_meta($post->ID, 'mr_pb_des', $_POST['mr_pb_des']); */
  874. /* update_post_meta($post->ID, 'mr_conclusion_des', $_POST['mr_conclusion_des']); */
  875. update_post_meta($post->ID, 'site_id1', $_POST['site_id1']);
  876. update_post_meta($post->ID, 'site_id2', $_POST['site_id2']);
  877. update_post_meta($post->ID, 'site_id3', $_POST['site_id3']);
  878. update_post_meta($post->ID, 'site_id4', $_POST['site_id4']);
  879. update_post_meta($post->ID, 'site_id5', $_POST['site_id5']);
  880. update_post_meta($post->ID, 'site_id6', $_POST['site_id6']);
  881. update_post_meta($post->ID, 'site_id7', $_POST['site_id7']);
  882. update_post_meta($post->ID, 'site_id8', $_POST['site_id8']);
  883. update_post_meta($post->ID, 'mr_discountbutton_url', $_POST['mr_discountbutton_url']);
  884. update_post_meta($post->ID, 'today_offer', $_POST['today_offer']);
  885. }
  886. if($post->post_type == 'model')
  887. {
  888. $mr_modelSite=implode(",",$_POST['mr_modelSite']);
  889. update_post_meta($post->ID,"mr_model_appear_sites",$mr_modelSite);
  890. }
  891. if($post->post_type == 'mrsite')
  892. {
  893. $mr_siteCustomUrl=$_POST['mr_siteCustomUrl'];
  894. update_post_meta($post->ID,"mr_siteCustomUrl",$mr_siteCustomUrl);
  895. }
  896. if($post->post_type == 'freegallery')
  897. {
  898. /* update_post_meta($post->ID, 'mr_freeGallery_type', $_POST['mr_freeGallery_type']); */
  899. update_post_meta($post->ID, 'gallery_bannercode', $_POST['gallery_bannercode']);
  900. update_post_meta($post->ID, 'gallery_bottomtext', $_POST['gallery_bottomtext']);
  901. update_post_meta($post->ID, 'mr_freeGalleryModel', $_POST['mr_freeGalleryModel']);
  902. update_post_meta($post->ID, 'mr_freeGalleryModel_2', $_POST['mr_freeGalleryModel_2']);
  903. update_post_meta($post->ID, 'mr_freeGalleryDate', $_POST['mr_freeGalleryDate']);
  904. update_post_meta($post->ID, 'mr_freeGallerySite_name', $_POST['mr_freeGallerySite']);
  905. update_post_meta($post->ID, 'mr_freeGallerySite_url', $_POST['mr_freeGallerySiteUrl']);
  906. if($_POST['mr_freeG_website']){
  907. update_post_meta($post->ID, 'mr_freeG_website', $_POST['mr_freeG_website']);
  908. global $wpdb;
  909. $postTab = $wpdb->prefix."posts";
  910. $mr_freeG_website=$_POST['mr_freeG_website'];
  911. $zz = $wpdb->query( $wpdb->prepare( "UPDATE $postTab
  912. SET post_parent =$mr_freeG_website WHERE ID = $post->ID") );
  913. }
  914. else{
  915. update_post_meta($post->ID, 'mr_freeG_website', '');
  916. global $wpdb;
  917. $postTab = $wpdb->prefix."posts";
  918. $mr_freeG_website=$_POST['mr_freeG_website'];
  919. $zz = $wpdb->query( $wpdb->prepare( "UPDATE $postTab
  920. SET post_parent =0 WHERE ID = $post->ID") );
  921. }
  922. }
  923. if($post->post_type == 'freevideo')
  924. {
  925. update_post_meta($post->ID, 'video_bannercode', $_POST['video_bannercode']);
  926. update_post_meta($post->ID, 'video_bottomtext', $_POST['video_bottomtext']);
  927. update_post_meta($post->ID, 'mr_freeVideoUrl', $_POST['mr_freeVideoUrl']);
  928. update_post_meta($post->ID, 'mr_freeV_model', $_POST['mr_freeVideoModel']);
  929. update_post_meta($post->ID, 'mr_freeV_model2', $_POST['mr_freeVideoModel2']);
  930. if($_POST['mr_freeV_website']){
  931. update_post_meta($post->ID, 'mr_freeV_website', $_POST['mr_freeV_website']);
  932. global $wpdb;
  933. $postTab = $wpdb->prefix."posts";
  934. $mr_freeV_website=$_POST['mr_freeV_website'];
  935. $zz = $wpdb->query( $wpdb->prepare( "UPDATE $postTab
  936. SET post_parent =$mr_freeV_website WHERE ID = $post->ID") );
  937. }
  938. else{
  939. update_post_meta($post->ID, 'mr_freeV_website', '');
  940. global $wpdb;
  941. $postTab = $wpdb->prefix."posts";
  942. $mr_freeV_website=$_POST['mr_freeV_website'];
  943. $zz = $wpdb->query( $wpdb->prepare( "UPDATE $postTab
  944. SET post_parent =0 WHERE ID = $post->ID") );
  945. }
  946. }
  947. /* #################################### End Code #######################*/
  948. }
  949. function mr_gallerydata_sectionfun()
  950. {
  951. global $post;
  952. $galleryId = $post->ID;
  953. $galleryParent = wp_get_post_parent_id($galleryId )
  954. ?>
  955. <style type="text/css">
  956. .mr-add-gallery-secOut input[type="text"] {
  957. width: 80%;
  958. }
  959. #free-GLR-containt th { background: #000 none repeat scroll 0 0; border: 1px solid #444; color: #fff; padding: 5px;
  960. text-align: start;}
  961. #free-GLR-containt td {padding: 5px; border: 1px solid #444; }
  962. .free-gallery-list-out{margin-top:40px;}
  963. .suss-mess{text-algin:center; color:green;}
  964. </style>
  965. <div style="text-algin:center;color:green;" id="succ-mess"></div>
  966. <div class="mr-add-gallery-secOut">
  967. <a href="<?php echo get_edit_post_link($galleryParent); ?>" class="button-primary button-large">
  968. Go to parent post >></a>
  969. <br><br>
  970. <table width="70%" >
  971. <tr>
  972. <td>Banner Code</td>
  973. <td>
  974. <textarea style="width:100%;min-height:100px;" name="gallery_bannercode" id="gallery_bannercode" ><?php echo get_post_meta($galleryId,"gallery_bannercode",true); ?></textarea>
  975. </td>
  976. </tr>
  977. <tr>
  978. <td>Bottom Text Code</td>
  979. <td>
  980. <textarea style="width:100%;min-height:100px;" name="gallery_bottomtext" id="gallery_bottomtext" ><?php echo get_post_meta($galleryId,"gallery_bottomtext",true); ?></textarea>
  981. </td>
  982. </tr>
  983. <tr style="display:none;">
  984. <td>Site Name</td>
  985. <td>
  986. <input type="text" style="float:left; width:48%" placeholder="Enter Site Name" value="<?php echo get_post_meta($galleryId,"mr_freeGallerySite_name",true); ?>"
  987. name="mr_freeGallerySite" id="mr_freeGallerySite"/>
  988. <input type="text" name="mr_freeGallerySiteUrl" id="mr_freeGallerySiteUrl" value="<?php echo get_post_meta($galleryId,"mr_freeGallerySite_url",true); ?>" style="float:right; width:49%" placeholder="Site url" />
  989. </td>
  990. </tr>
  991. <tr>
  992. <td>Model</td>
  993. <td>
  994. <?php
  995. $mr_freeGalleryID =get_post_meta($galleryId,"mr_freeGalleryModel",true);
  996. ?>
  997. <select name="mr_freeGalleryModel" id="mr_freeGalleryModel">
  998. <option value="">Select</option>
  999. <?php
  1000. $args = array('post_type' => 'model','post_status' => 'publish','orderby' => 'post_title','order' => 'ASC','posts_per_page' => -1);
  1001. $my_query = null;
  1002. $my_query = new WP_Query($args);
  1003. if($my_query->have_posts())
  1004. {
  1005. while($my_query->have_posts()) : $my_query->the_post();
  1006. $model_id = get_the_ID();
  1007. ?>
  1008. <option <?php if($mr_freeGalleryID==$model_id){echo "selected"; }?>
  1009. value="<?php echo $model_id; ?>"><?php echo get_the_title(); ?></option>
  1010. <?php
  1011. endwhile;
  1012. }
  1013. wp_reset_query();
  1014. ?>
  1015. </select>
  1016. </td>
  1017. </tr>
  1018. <tr>
  1019. <td>Model#2</td>
  1020. <td>
  1021. <?php
  1022. $mr_freeGalleryID =get_post_meta($galleryId,"mr_freeGalleryModel_2",true);
  1023. ?>
  1024. <select name="mr_freeGalleryModel_2" id="mr_freeGalleryModel_2">
  1025. <option value="">Select</option>
  1026. <?php
  1027. $args = array('post_type' => 'model','post_status' => 'publish','orderby' => 'post_title','order' => 'ASC','posts_per_page' => -1);
  1028. $my_query = null;
  1029. $my_query = new WP_Query($args);
  1030. if($my_query->have_posts())
  1031. {
  1032. while($my_query->have_posts()) : $my_query->the_post();
  1033. $model_id = get_the_ID();
  1034. ?>
  1035. <option <?php if($mr_freeGalleryID==$model_id){echo "selected"; }?>
  1036. value="<?php echo $model_id; ?>"><?php echo get_the_title(); ?></option>
  1037. <?php
  1038. endwhile;
  1039. }
  1040. wp_reset_query();
  1041. ?>
  1042. </select>
  1043. </td>
  1044. </tr>
  1045. <tr>
  1046. <td>Website</td><td>
  1047. <?php
  1048. $mr_freeG_website = get_post_meta($galleryId,'mr_freeG_website',true);
  1049. ?>
  1050. <select name="mr_freeG_website" id="mr_freeG_website">
  1051. <option value="">Select</option>
  1052. <?php
  1053. $args = array('post_type' => 'post','post_status' => 'publish','orderby' => 'post_title','order' => 'ASC','posts_per_page' => -1);
  1054. $my_query = null;
  1055. $my_query = new WP_Query($args);
  1056. if($my_query->have_posts())
  1057. {
  1058. while($my_query->have_posts()) : $my_query->the_post();
  1059. $web_id = get_the_ID();
  1060. ?>
  1061. <option <?php if($mr_freeG_website==$web_id){echo "selected"; }?>
  1062. value="<?php echo $web_id; ?>"><?php echo get_the_title(); ?></option>
  1063. <?php
  1064. endwhile;
  1065. }
  1066. wp_reset_query();
  1067. ?>
  1068. </select>
  1069. </td>
  1070. </tr>
  1071. </table>
  1072. </div>
  1073. <?php
  1074. }
  1075. function mr_video_data_sectionfun()
  1076. {
  1077. global $post;
  1078. $videoId = $post->ID;
  1079. $videoParent = wp_get_post_parent_id($videoId )
  1080. ?>
  1081. <style type="text/css">
  1082. .mr-add-video-secOut input[type="text"] {
  1083. width: 70%;
  1084. }
  1085. #free-GVLR-containt th { background: #000 none repeat scroll 0 0; border: 1px solid #444; color: #fff; padding: 5px;
  1086. text-align: start;}
  1087. #free-GVLR-containt td {padding: 5px; border: 1px solid #444; }
  1088. .free-gallery-video-out{margin-top:40px;}
  1089. .video-succ-mess{text-algin:center; color:green;}
  1090. .attachment-thumbnail.wp-post-image {
  1091. height: 50px;
  1092. width: 60px !important;
  1093. } }
  1094. </style>
  1095. <div style="text-algin:center;color:green;" id="video-succ-mess"></div>
  1096. <div class="mr-add-video-secOut">
  1097. <a href="<?php echo get_edit_post_link($videoParent); ?>" class="button-primary button-large">
  1098. Go to parent post >></a>
  1099. <form method="post" id="freeVideofrm">
  1100. <table width="75%" >
  1101. <tr>
  1102. <td>Banner Code</td>
  1103. <td>
  1104. <textarea style="width:100%;min-height:100px;" name="video_bannercode" id="video_bannercode" ><?php echo get_post_meta($videoId,"video_bannercode",true); ?></textarea>
  1105. </td>
  1106. </tr>
  1107. <tr>
  1108. <td>Bottom Text Code</td>
  1109. <td>
  1110. <textarea style="width:100%;min-height:100px;" name="video_bottomtext" id="video_bottomtext" ><?php echo get_post_meta($videoId,"video_bottomtext",true); ?></textarea>
  1111. </td>
  1112. </tr>
  1113. <tr >
  1114. <td>Free Video url</td><td>
  1115. <input type="text" name="mr_freeVideoUrl" value="<?php echo get_post_meta($videoId,"mr_freeVideoUrl",true); ?>" id="mr_freeVideoUrl">
  1116. </td>
  1117. </tr>
  1118. <tr>
  1119. <td>Model</td><td>
  1120. <?php
  1121. $mr_freeVideoModelId = get_post_meta($videoId,'mr_freeV_model',true);
  1122. ?>
  1123. <select name="mr_freeVideoModel" id="mr_freeVideoModel">
  1124. <option value="">Select</option>
  1125. <?php
  1126. $args = array('post_type' => 'model','post_status' => 'publish','orderby' => 'post_title','order' => 'ASC','posts_per_page' => -1);
  1127. $my_query = null;
  1128. $my_query = new WP_Query($args);
  1129. if($my_query->have_posts())
  1130. {
  1131. while($my_query->have_posts()) : $my_query->the_post();
  1132. $model_id = get_the_ID();
  1133. ?>
  1134. <option <?php if($mr_freeVideoModelId==$model_id){echo "selected"; }?>
  1135. value="<?php echo $model_id; ?>"><?php echo get_the_title(); ?></option>
  1136. <?php
  1137. endwhile;
  1138. }
  1139. wp_reset_query();
  1140. ?>
  1141. </select>
  1142. </td>
  1143. </tr>
  1144. <tr>
  1145. <td>Model#2</td><td>
  1146. <?php $mr_freeVideoModelId = get_post_meta($videoId,'mr_freeV_model2',true); ?>
  1147. <select name="mr_freeVideoModel2" id="mr_freeVideoModel2">
  1148. <option value="">Select</option>
  1149. <?php $args = array('post_type' => 'model','post_status' => 'publish','orderby' => 'post_title','order' => 'ASC','posts_per_page' => -1);
  1150. $my_query = null;
  1151. $my_query = new WP_Query($args);
  1152. if($my_query->have_posts())
  1153. {
  1154. while($my_query->have_posts()) : $my_query->the_post();
  1155. $model_id = get_the_ID(); ?>
  1156. <option <?php if($mr_freeVideoModelId==$model_id){echo "selected"; }?> value="<?php echo $model_id; ?>"><?php echo get_the_title(); ?></option> <?php endwhile; } wp_reset_query(); ?> </select> </td>
  1157. </tr>
  1158. <tr>
  1159. <td>Website</td><td>
  1160. <?php
  1161. $mr_freeVideowebId = get_post_meta($videoId,'mr_freeV_website',true);
  1162. ?>
  1163. <select name="mr_freeV_website" id="mr_freeV_website">
  1164. <option value="">Select</option>
  1165. <?php
  1166. $args = array('post_type' => 'post','post_status' => 'publish','orderby' => 'post_title','order' => 'ASC','posts_per_page' => -1);
  1167. $my_query = null;
  1168. $my_query = new WP_Query($args);
  1169. if($my_query->have_posts())
  1170. {
  1171. while($my_query->have_posts()) : $my_query->the_post();
  1172. $web_id = get_the_ID();
  1173. ?>
  1174. <option <?php if($mr_freeVideowebId==$web_id){echo "selected"; }?>
  1175. value="<?php echo $web_id; ?>"><?php echo get_the_title(); ?></option>
  1176. <?php
  1177. endwhile;
  1178. }
  1179. wp_reset_query();
  1180. ?>
  1181. </select>
  1182. </td>
  1183. </tr>
  1184. </table>
  1185. </form>
  1186. </div>
  1187. <?php
  1188. }
  1189. /* // Free Galleries Section */
  1190. function mr_free_galleryBox_callback()
  1191. {
  1192. global $post;
  1193. $mrpostParent =$post->ID;
  1194. ?>
  1195. <script type="text/javascript">
  1196. jQuery(document).ready(function(){
  1197. jQuery('#add_fG_Submit_reset').click(function(){
  1198. jQuery('#mr_freeGalleryTitle').val('');
  1199. jQuery('#gallery_bannercode').val('');
  1200. jQuery('#mr_freeGalleryModel').val('');
  1201. jQuery('#mr_freeGalleryModel_2').val('');
  1202. jQuery('#mr_freeGalleryDate').val('');
  1203. });
  1204. jQuery("#add_freegallerySubmit").click(function()
  1205. {
  1206. var freeG_Title = jQuery("#mr_freeGalleryTitle").val();
  1207. var freeG_Url = jQuery("#gallery_bannercode").val();
  1208. var freeG_type = jQuery("#mr_freeGallery_type").val();
  1209. var freeG_Model = jQuery("#mr_freeGalleryModel").val();
  1210. var freeG_Model_2 = jQuery("#mr_freeGalleryModel_2").val();
  1211. var freeG_Date = jQuery("#mr_freeGalleryDate").val();
  1212. var freeG_image = jQuery("#mr_freeGImage").val();
  1213. var freeG_SiteN = jQuery("#mr_freeGallerySite").val();
  1214. var freeG_SiteUrl = jQuery("#mr_freeGallerySiteUrl").val();
  1215. var fg_parentID ="<?php echo $post->ID; ?>";
  1216. jQuery.ajax({
  1217. url: "<?php echo get_template_directory_uri();?>/mr-reg-post.php",
  1218. method: "POST",
  1219. data: {fg_title:freeG_Title,gelley_url:freeG_Url,fg_type:freeG_type,fG_image:freeG_image,fG_Model:freeG_Model,fG_Model_2:freeG_Model_2,fG_Date:freeG_Date,fg_parentID:fg_parentID,fg_siteName:freeG_SiteN,fg_siteUrl:freeG_SiteUrl},
  1220. success: function(result)
  1221. {
  1222. jQuery("#succ-mess").html(result);
  1223. jQuery('#mr_freeGalleryTitle').val('');
  1224. jQuery('#gallery_bannercode').val('');
  1225. jQuery('#mr_freeGalleryModel').val('');
  1226. jQuery('#mr_freeGalleryModel_2').val('');
  1227. jQuery('#mr_freeGalleryDate').val('');
  1228. jQuery('#mr_freeGImage').val('');
  1229. jQuery('#mr_freeGallerySite').val('');
  1230. jQuery('#mr_freeGallerySiteUrl').val('');
  1231. }
  1232. });
  1233. });
  1234. });
  1235. </script>
  1236. <style type="text/css">
  1237. .mr-add-gallery-secOut input[type="text"] {
  1238. width: 60%;
  1239. }
  1240. #free-GLR-containt th { background: #000 none repeat scroll 0 0; border: 1px solid #444; color: #fff; padding: 5px;
  1241. text-align: start;}
  1242. #free-GLR-containt td {padding: 5px; border: 1px solid #444; }
  1243. .free-gallery-list-out{margin-top:40px;}
  1244. .suss-mess{text-algin:center; color:green;}
  1245. </style>
  1246. <div style="text-algin:center;color:green;" id="succ-mess"></div>
  1247. <div class="mr-add-gallery-secOut">
  1248. <form method="post" id="freeGaleryfrm">
  1249. <table width="70%" >
  1250. <tr>
  1251. <td widget="150px">Free gallery title</td>
  1252. <td><input type="text" name="mr_freeGalleryTitle" id="mr_freeGalleryTitle" ></td>
  1253. </tr>
  1254. <tr>
  1255. <td>Free gallery url</td>
  1256. <td><input type="text" name="gallery_bannercode" id="gallery_bannercode" ></td>
  1257. </tr>
  1258. <tr>
  1259. <td>Type</td>
  1260. <td>
  1261. <select name="mr_freeGallery_type" id="mr_freeGallery_type">
  1262. <option value="video">Video</option>
  1263. <option value="gallery">Gallery</option>
  1264. </select>
  1265. </td>
  1266. </tr>
  1267. <tr >
  1268. <td>Site Name</td>
  1269. <td>
  1270. <input type="text" style="float:left; width:48%" placeholder="Enter Site Name" name="mr_freeGallerySite" id="mr_freeGallerySite"/>
  1271. <input type="text" name="mr_freeGallerySiteUrl" id="mr_freeGallerySiteUrl" style="float:right; width:49%" placeholder="Site url" />
  1272. </td>
  1273. </tr>
  1274. <tr>
  1275. <td>Model</td>
  1276. <td>
  1277. <select name="mr_freeGalleryModel" id="mr_freeGalleryModel">
  1278. <option value="">Select</option>
  1279. <?php
  1280. //$mr_ModelId =get_post_meta($mrpostParent,"mr_freeGalleryModel",true);
  1281. $args = array('post_type' => 'model',
  1282. 'post_status' => 'publish',
  1283. 'orderby' => 'post_title',
  1284. 'order' => 'ASC',
  1285. 'posts_per_page' => -1);
  1286. $my_query = null;
  1287. $my_query = new WP_Query($args);
  1288. if( $my_query->have_posts() )
  1289. {
  1290. while ($my_query->have_posts()) : $my_query->the_post();
  1291. $mdoel_id = get_the_ID();
  1292. echo '<option value="'.$mdoel_id.'">'.get_the_title().'</option>';
  1293. endwhile;
  1294. }
  1295. wp_reset_query();
  1296. ?>
  1297. </select>
  1298. </td>
  1299. </tr>
  1300. <tr>
  1301. <td>Model#2</td>
  1302. <td>
  1303. <select name="mr_freeGalleryModel_2" id="mr_freeGalleryModel_2">
  1304. <option value="">Select</option>
  1305. <?php /*$mr_ModelId =get_post_meta($mrpostParent,"mr_freeV_model",true);*/
  1306. $args = array('post_type' => 'model','post_status' => 'publish','orderby' => 'post_title','order' => 'ASC','posts_per_page' => -1);
  1307. $my_query = null;
  1308. $my_query = new WP_Query($args);
  1309. if($my_query->have_posts())
  1310. {
  1311. while($my_query->have_posts()) : $my_query->the_post();
  1312. $model_id = get_the_ID(); ?>
  1313. <option <?php if($mr_ModelId==$model_id){echo "selected"; }?>
  1314. value="<?php echo $model_id; ?>"><?php echo get_the_title(); ?>
  1315. </option>
  1316. <?php
  1317. endwhile;
  1318. }
  1319. wp_reset_query();
  1320. ?>
  1321. </select>
  1322. </td>
  1323. </tr>
  1324. <tr>
  1325. <td>Enter Date</td><td><input type="text" name="mr_freeGalleryDate" id="mr_freeGalleryDate" placeholder="01/18/15"></td>
  1326. </tr>
  1327. <tr>
  1328. <td valign="top">Gallery Image</td>
  1329. <td>
  1330. <input type="text" id="mr_freeGImage" name="mr_freeGImage" placeholder="Enter thumbnail url" style="float:left;" value="">
  1331. <input id="btn_g1" class="button-primary upload_image_button_g" type="button" value="Upload Image" style="width:100px;float:left;" />
  1332. </td>
  1333. </tr>
  1334. <tr>
  1335. <td align="center">
  1336. <input type="button" name="add_fG_Submit_reset" id="add_fG_Submit_reset" value="Clear" class="button button-primary button-large">
  1337. </td>
  1338. <td align="center">
  1339. <input type="button" name="add_freegallerySubmit" id="add_freegallerySubmit" value="Submit" class="button button-primary button-large">
  1340. </td>
  1341. </tr>
  1342. </table>
  1343. </form>
  1344. </div><hr>
  1345. <div class="free-gallery-list-out">
  1346. <?php
  1347. global $wpdb;
  1348. $postTab = $wpdb->prefix."posts";
  1349. if(isset($_REQUEST['delFgpostId']))
  1350. {
  1351. $delFgpostId = $_REQUEST['delFgpostId'];
  1352. $fgppdel_succ = wp_delete_post($delFgpostId,true);
  1353. if($fgppdel_succ)
  1354. {
  1355. echo "<h2 class='suss-mess'>Gallery Delete successfully.</h2>";
  1356. //wp_redirect(get_edit_post_link($mrpostParent));
  1357. ?>
  1358. <script type="text/javascript">
  1359. window.location="<?php echo '?post='.$mrpostParent.'&action=edit'; ?>";
  1360. </script>
  1361. <?php
  1362. }
  1363. }
  1364. $listFgpost =$wpdb->get_results("select * from $postTab where post_type='freegallery' and post_status='publish' and post_parent='$mrpostParent' order by ID DESC limit 0,15");
  1365. ?>
  1366. <div id="free-GLR-containt">
  1367. <table width="100%" border="1" cellpadding="0" cellspacing="0">
  1368. <thead>
  1369. <tr><th>Gallery</th> <th>Type</th><th>Model</th><th>Site</th><th>Date</th><th width="100px">Option</th></tr>
  1370. </thead>
  1371. <tbody>
  1372. <?php
  1373. if($listFgpost && $wpdb->num_rows>0)
  1374. {
  1375. /* while($=mysql_fetch_array($listFgpost)) */
  1376. foreach($listFgpost as $res)
  1377. {
  1378. /* extract($res); */
  1379. ?>
  1380. <tr>
  1381. <td><?php echo $res->post_title; ?></td>
  1382. <td><?php echo get_post_meta($res->ID,'mr_freeGallery_type',true); ?></td>
  1383. <td>
  1384. <?php
  1385. $modelId = get_post_meta($res->ID,'mr_freeGalleryModel',true);
  1386. $modeldetail_Data = get_post($modelId);
  1387. $modelName = $modeldetail_Data->post_title;
  1388. echo $modelName;
  1389. ?></td>
  1390. <td><?php echo get_post_meta($res->ID,'mr_freeGallerySite_name',true); ?></td>
  1391. <td><?php echo get_post_meta($res->ID,'mr_freeGalleryDate',true); ?></td>
  1392. <td>
  1393. <a class="button button-primary button-small" href="<?php echo get_edit_post_link($res->ID); ?>" target="_blank">Edit</a>
  1394. <a class="button button-primary button-small" onclick="return confirm('Are you sure want to delete ?')"
  1395. href="?post=<?php echo $mrpostParent; ?>&action=edit&delFgpostId=<?php echo $ID; ?>">Delete</a>
  1396. </td>
  1397. </tr>
  1398. <?php
  1399. }
  1400. }
  1401. else{
  1402. ?><tr><td colspan="5" align="center"><font color="red">No records</font></td></tr><?php
  1403. }
  1404. ?>
  1405. <tbody>
  1406. </table>
  1407. </div>
  1408. </div>
  1409. <?php
  1410. }
  1411. function randon_post($post){ ?>
  1412. <table width="75%" >
  1413. <tr> <?php $random_post =get_post_meta($post->ID,"mr_random_post",true); ?>
  1414. <td>Random</td>
  1415. <td><input type="checkbox" name="mr_random_post" id="mr_random_post" value="random_post" <?php if($random_post=='random_post'){ echo "checked"; } ?> ></td>
  1416. </tr>
  1417. <tr> <?php $feature_video =get_post_meta($post->ID,"mr_feature_video",true); ?>
  1418. <td> Feature Video Id </td>
  1419. <td><input type="text" name="mr_feature_video" id="mr_feature_video" value="<?php echo $feature_video; ?>" ></td>
  1420. </tr>
  1421. </table>
  1422. <?php }
  1423. function magnifying_glass($post){ ?>
  1424. <table width="75%" >
  1425. <tr> <?php $random_post =get_post_meta($post->ID,"mr_magnifying_glass",true); ?>
  1426. <td>Show Magnifying Glass</td>
  1427. <td><input type="checkbox" name="mr_magnifying_glass" id="mr_magnifying_glass" value="magnifying_glass" <?php if($random_post=='magnifying_glass'){ echo "checked"; }?> ></td>
  1428. </tr>
  1429. </table>
  1430. <?php }
  1431. function custom_tag_fields($post){ ?>
  1432. <table width="75%" >
  1433. <tr> <?php $catag =get_post_meta($post->ID,"catag",true); ?>
  1434. <td>Categ</td>
  1435. <td><input type="text" name="catag" id="catag" value="<?php echo $catag; ?>"></td>
  1436. </tr>
  1437. <tr> <?php $domaintag =get_post_meta($post->ID,"domaintag",true); ?>
  1438. <td>Domain Tag</td>
  1439. <td><input type="text" name="domaintag" id="domaintag" value="<?php echo $domaintag; ?>"></td>
  1440. </tr>
  1441. <tr>
  1442. <?php $external_link =get_post_meta($post->ID,"post_external_link",true); ?>
  1443. <td>Post External Link</td>
  1444. <td><input type="text" name="post_external_link" id="post_external_link" value="<?php echo $external_link; ?>"></td>
  1445. </tr>
  1446. <tr>
  1447. <?php $join_external_link =get_post_meta($post->ID,"joink_external_link",true); ?>
  1448. <td>Join External Link</td>
  1449. <td><input type="text" name="joink_external_link" id="joink_external_link" value="<?php echo $join_external_link; ?>"></td>
  1450. </tr>
  1451. <tr> <?php $titletag =htmlspecialchars(get_post_meta($post->ID,"titletag",true)) ; ?>
  1452. <td>Title Tag</td>
  1453. <td><input type="text" name="titletag" id="titletag" value="<?php echo $titletag; ?>"></td>
  1454. </tr>
  1455. </table>
  1456. <style>
  1457. #mr-extra_tag-section input {
  1458. width: 350px;
  1459. }
  1460. </style>
  1461. <?php }
  1462. function discount_extra_sites($post){
  1463. ?>
  1464. <div class="discount-extra-site">
  1465. <p>Select Extra Discounted Sites</p>
  1466. <?php
  1467. $sites_discounted = get_post_meta( $post->ID, 'discount-extra-site', true );
  1468. ?>
  1469. <Select name="discount-extra-site[]" multiple >
  1470. <?php
  1471. query_posts( 'post_type=post&orderby=title&order=ASC' );
  1472. while ( have_posts() ) : the_post(); ?>
  1473. <option value="<?php the_ID(); ?>" <?php if (@in_array(get_the_ID(), $sites_discounted)){ echo "selected";
  1474. } ?> ><?php the_title(); ?></option>
  1475. <?php endwhile; ?>
  1476. </select>
  1477. </div>
  1478. <?php
  1479. }
  1480. function feature_box_fields($post){ ?>
  1481. <table width="75%">
  1482. <tr>
  1483. <td widget="150px">Feature 1</td>
  1484. <td><input type="text" class="full-width" name="mr_feature1" id="mr_feature1" value="<?php echo get_post_meta($post->ID,"mr_feature1",true); ?>"></td>
  1485. </tr>
  1486. <tr>
  1487. <td widget="150px">Feature 2</td>
  1488. <td><input type="text" class="full-width" name="mr_feature2" id="mr_feature2" value="<?php echo get_post_meta($post->ID,"mr_feature2",true); ?>"></td>
  1489. </tr>
  1490. <tr>
  1491. <td widget="150px">Feature 3</td>
  1492. <td><input type="text" class="full-width" name="mr_feature3" id="mr_feature3" value="<?php echo get_post_meta($post->ID,"mr_feature3",true); ?>"></td>
  1493. </tr>
  1494. <tr>
  1495. <td widget="150px">Feature 4</td>
  1496. <td><input type="text" class="full-width" name="mr_feature4" id="mr_feature4" value="<?php echo get_post_meta($post->ID,"mr_feature4",true); ?>"></td>
  1497. </tr>
  1498. <tr>
  1499. <td widget="150px">Feature 5</td>
  1500. <td><input type="text" class="full-width" name="mr_feature5" id="mr_feature5" value="<?php echo get_post_meta($post->ID,"mr_feature5",true); ?>"></td>
  1501. </tr>
  1502. <tr>
  1503. <td widget="150px">Feature 6</td>
  1504. <td><input type="text" class="full-width" name="mr_feature6" id="mr_feature6" value="<?php echo get_post_meta($post->ID,"mr_feature6",true); ?>"></td>
  1505. </tr>
  1506. </table>
  1507. <?php }
  1508. function price_table_fields($post){
  1509. ?>
  1510. <table width="75%" >
  1511. <tr><th></th><th>Price</th><th>Off</th><th>Last Price</th><th>Per Month</th></tr>
  1512. <tr>
  1513. <td widget="150px">Per Month</td>
  1514. <td><input type="text" name="mr_month_price" id="mr_month_price" value="<?php echo get_post_meta($post->ID,"mr_month_price",true); ?>"></td>
  1515. <td><input type="text" name="mr_month_off" id="mr_month_off" value="<?php echo get_post_meta($post->ID,"mr_month_off",true); ?>"></td>
  1516. <td><input type="text" name="mr_month_lastrice" id="mr_month_lastrice" value="<?php echo get_post_meta($post->ID,"mr_month_lastrice",true); ?>"></td>
  1517. <td><input type="text" name="mr_month_price_2" id="mr_month_price_2" value="<?php echo get_post_meta($post->ID,"mr_month_price",true); ?>"></td>
  1518. </tr>
  1519. <tr>
  1520. <td widget="150px">Per 3 Months</td>
  1521. <td><input type="text" name="mr_sixmonth_price" id="mr_sixmonth_price" value="<?php echo get_post_meta($post->ID,"mr_sixmonth_price",true); ?>"></td>
  1522. <td><input type="text" name="mr_sixmonth_off" id="mr_sixmonth_off" value="<?php echo get_post_meta($post->ID,"mr_sixmonth_off",true); ?>"></td>
  1523. <td><input type="text" name="mr_sixmonth_lastrice" id="mr_sixmonth_lastrice" value="<?php echo get_post_meta($post->ID,"mr_sixmonth_lastrice",true); ?>"></td>
  1524. <td><input type="text" name="mr_per_month3" id="mr_per_month3" value="<?php echo get_post_meta($post->ID,"mr_per_month3",true); ?>"></td>
  1525. </tr>
  1526. <tr>
  1527. <td widget="150px">Per 6 Months</td>
  1528. <td><input type="text" name="mr_threeyear_price" id="mr_threeyear_price" value="<?php echo get_post_meta($post->ID,"mr_threeyear_price",true); ?>"></td>
  1529. <td><input type="text" name="mr_threeyear_off" id="mr_threeyear_off" value="<?php echo get_post_meta($post->ID,"mr_threeyear_off",true); ?>"></td>
  1530. <td><input type="text" name="mr_threeyear_lastrice" id="mr_threeyear_lastrice" value="<?php echo get_post_meta($post->ID,"mr_threeyear_lastrice",true); ?>"></td>
  1531. <td><input type="text" name="mr_per_month6" id="mr_per_month6" value="<?php echo get_post_meta($post->ID,"mr_per_month6",true); ?>"></td>
  1532. </tr>
  1533. <tr>
  1534. <td widget="150px">Per 1 Year</td>
  1535. <td><input type="text" name="mr_fiveyear_price" id="mr_fiveyear_price" value="<?php echo get_post_meta($post->ID,"mr_fiveyear_price",true); ?>"></td>
  1536. <td><input type="text" name="mr_fiveyear_off" id="mr_fiveyear_off" value="<?php echo get_post_meta($post->ID,"mr_fiveyear_off",true); ?>"></td>
  1537. <td><input type="text" name="mr_fiveyear_lastrice" id="mr_fiveyear_lastrice" value="<?php echo get_post_meta($post->ID,"mr_fiveyear_lastrice",true); ?>"></td>
  1538. <td><input type="text" name="mr_per_month12" id="mr_per_month12" value="<?php echo get_post_meta($post->ID,"mr_per_month12",true); ?>"></td>
  1539. </tr>
  1540. </table>
  1541. <?php
  1542. }
  1543. function discount_price_fields($post){ ?>
  1544. <table width="75%" >
  1545. <tr> <?php $active_discount =get_post_meta($post->ID,"mr_active_discount",true);
  1546. $top_deal_discount =get_post_meta($post->ID,"mr_topdeal_discount",true);
  1547. $lifetime_discount =get_post_meta($post->ID,"mr_lifetime_discount",true);
  1548. $new_discount =get_post_meta($post->ID,"mr_new_discount",true); ?>
  1549. <td>Active</td>
  1550. <td><input type="checkbox" name="mr_active_discount" id="mr_active_discount" value="active" <?php if($active_discount=='active'){ echo "checked"; }?> ></td>
  1551. </tr>
  1552. <tr>
  1553. <td>Top Deal</td>
  1554. <td><input type="checkbox" name="mr_topdeal_discount" id="mr_topdeal_discount" value="top_deal" <?php if($top_deal_discount=='top_deal'){ echo "checked"; }?>></td>
  1555. </tr>
  1556. <tr>
  1557. <td>New</td>
  1558. <td><input type="checkbox" name="mr_new_discount" id="mr_new_discount" value="new" <?php if($new_discount=='new'){ echo "checked"; }?>></td>
  1559. </tr>
  1560. <tr>
  1561. <td>Lifetime Discount</td>
  1562. <td><input type="checkbox" name="mr_lifetime_discount" id="mr_lifetime_discount" value="lifetime"<?php if($lifetime_discount=='lifetime'){ echo "checked"; }?> ></td>
  1563. </tr>
  1564. <!--<tr>
  1565. <td widget="150px">Old Price</td>
  1566. <td><input type="text" name="mr_regularprice" id="mr_regularprice" value="<?php echo get_post_meta($post->ID,"mr_regularprice",true); ?>"></td>
  1567. </tr>
  1568. <tr>
  1569. <td widget="150px">New Price</td>
  1570. <td><input type="text" name="mr_saleprice" id="mr_saleprice" value="<?php echo get_post_meta($post->ID,"mr_saleprice",true); ?>"></td>
  1571. </tr>
  1572. <tr>
  1573. <td widget="150px">Discount %</td>
  1574. <td><input type="text" name="mr_discountprice" id="mr_discountprice" value="<?php echo get_post_meta($post->ID,"mr_discountprice",true); ?>" ></td>
  1575. </tr> -->
  1576. <tr>
  1577. <td>Description</td>
  1578. <td><textarea class="full-width" name="mr_discount_des" size="25" id="mr_discount_des"><?php echo get_post_meta($post->ID,"mr_discount_des",true); ?></textarea></td>
  1579. </tr>
  1580. <tr>
  1581. <td valign="top">Discount Image</td>
  1582. <td> <input type="text" value="<?php echo get_post_meta($post->ID,"mr_discount_Image",true); ?>" style="float:left;" placeholder="Enter thumbnail url" name="mr_discount_Image" id="mr_discount_Image"> <input type="button" style="width:100px;float:left;" value="Upload Image" class="button-primary upload_image_button_d" id="btn_2"> </td>
  1583. </tr>
  1584. <tr>
  1585. <td widget="150px">Buy Now Button Url</td>
  1586. <td><input type="text" name="mr_discountbutton_url" id="mr_discountbutton_url" value="<?php echo get_post_meta($post->ID,"mr_discountbutton_url",true); ?>"></td>
  1587. </tr>
  1588. </table>
  1589. <?php }
  1590. function more_born_sites($post){ ?>
  1591. <table>
  1592. <tr>More Born Sites</tr>
  1593. <tr><td>CategoryID 1</td>
  1594. <td><input type="text" name="site_id1" id="mr_feature1" value="<?php echo get_post_meta($post->ID,"site_id1",true); ?>"></td>
  1595. </tr>
  1596. <tr><td>CategoryID 2</td>
  1597. <td><input type="text" name="site_id2" id="mr_feature1" value="<?php echo get_post_meta($post->ID,"site_id2",true); ?>"></td>
  1598. </tr>
  1599. <tr><td>CategoryID 3</td>
  1600. <td><input type="text" name="site_id3" id="mr_feature1" value="<?php echo get_post_meta($post->ID,"site_id3",true); ?>"></td>
  1601. </tr>
  1602. <tr><td>CategoryID 4</td>
  1603. <td><input type="text" name="site_id4" id="mr_feature1" value="<?php echo get_post_meta($post->ID,"site_id4",true); ?>"></td>
  1604. </tr>
  1605. <tr><td>CategoryID 5</td>
  1606. <td><input type="text" name="site_id5" id="mr_feature1" value="<?php echo get_post_meta($post->ID,"site_id5",true); ?>"></td>
  1607. </tr>
  1608. <tr><td>CategoryID 6</td>
  1609. <td><input type="text" name="site_id6" id="mr_feature1" value="<?php echo get_post_meta($post->ID,"site_id6",true); ?>"></td>
  1610. </tr>
  1611. <tr><td>CategoryID 7</td>
  1612. <td><input type="text" name="site_id7" id="mr_feature1" value="<?php echo get_post_meta($post->ID,"site_id7",true); ?>"></td>
  1613. </tr>
  1614. <tr><td>CategoryID 8</td>
  1615. <td><input type="text" name="site_id8" id="mr_feature1" value="<?php echo get_post_meta($post->ID,"site_id8",true); ?>"></td>
  1616. </tr>
  1617. </table>
  1618. <?php }
  1619. function post_extra_desc($post){
  1620. ?>
  1621. <style>
  1622. .full-width {
  1623. width: 100%;
  1624. }
  1625. </style>
  1626. <table width="100%" >
  1627. <tr>
  1628. <td>Pros</td>
  1629. <td><textarea class="full-width" name="mr_quility_des" size="25" id="mr_quility_des"><?php echo get_post_meta($post->ID,"mr_quility_des",true); ?></textarea>
  1630. </td>
  1631. </tr>
  1632. <tr>
  1633. <td>Cons</td>
  1634. <td><textarea class="full-width" name="mr_content_des" size="25" id="mr_content_des"><?php echo get_post_meta($post->ID,"mr_content_des",true); ?></textarea>
  1635. </td>
  1636. </tr>
  1637. <!--
  1638. <tr>
  1639. <td>Pros</td>
  1640. <td><textarea name="mr_pros_des" size="25" id="mr_pros_des"><?php // echo get_post_meta($post->ID,"mr_pros_des",true); ?></textarea>
  1641. </td>
  1642. </tr>
  1643. <tr>
  1644. <td>Cons</td>
  1645. <td><textarea name="mr_cons_des" size="25" id="mr_cons_des"><?php // echo get_post_meta($post->ID,"mr_cons_des",true); ?></textarea>
  1646. </td>
  1647. </tr>
  1648. <tr>
  1649. <td>Price $ Bonus</td>
  1650. <td><textarea name="mr_pb_des" size="25" id="mr_pb_des"><?php // echo get_post_meta($post->ID,"mr_pb_des",true); ?></textarea>
  1651. </td>
  1652. </tr>
  1653. <tr>
  1654. <td>Conclusion</td>
  1655. <td><textarea name="mr_conclusion_des" size="25" id="mr_conclusion_des"><?php // echo get_post_meta($post->ID,"mr_conclusion_des",true); ?></textarea>
  1656. </td>
  1657. </tr>
  1658. -->
  1659. </table>
  1660. <?php
  1661. }
  1662. /* //Free Videos Sections */
  1663. function mr_free_videoBox_callback($post)
  1664. {
  1665. global $wpdb;
  1666. $postTab = $wpdb->prefix."posts";
  1667. ?>
  1668. <script type="text/javascript">
  1669. jQuery(document).ready(function(){
  1670. //Clear from
  1671. jQuery('#add_fV_Submit_reset').click(function(){
  1672. jQuery('#mr_freeVideoTitle').val('');
  1673. jQuery('#video_content').val('');
  1674. jQuery('#mr_freeVideoUrl').val('');
  1675. jQuery('#mr_freeImage_type').val('');
  1676. });
  1677. jQuery("#add_freeVideoSubmit").click(function()
  1678. {
  1679. var freeV_Title = jQuery("#mr_freeVideoTitle").val(); var freeV_Content = jQuery("#video_content").val();
  1680. var freeV_Url = jQuery("#mr_freeVideoUrl").val();
  1681. var freeV_image = jQuery("#mr_freeVImage").val();
  1682. var freeV_model = jQuery("#mr_freeVideoModel").val();
  1683. var freeV_model2 = jQuery("#mr_freeVideoModel_2").val();
  1684. var fv_parentID ="<?php echo $post->ID; ?>";
  1685. jQuery.ajax({
  1686. url: "<?php echo get_template_directory_uri();?>/mr-reg-post.php",
  1687. method: "POST",
  1688. data: {fv_title:freeV_Title,fV_Content:freeV_Content,fvideo_url:freeV_Url,fV_image:freeV_image,fV_model:freeV_model,fV_model2:freeV_model2,fv_parentID:fv_parentID},
  1689. success: function(mr_result)
  1690. {
  1691. jQuery("#video-succ-mess").html(mr_result);
  1692. jQuery('#mr_freeVideoTitle').val('');
  1693. jQuery('#video_content').val('');
  1694. jQuery('#mr_freeVideoUrl').val('');
  1695. jQuery('#mr_freeVImage').val('');
  1696. jQuery('#mr_freeVideoModel').val('');
  1697. jQuery('#mr_freeVideoModel_2').val('');
  1698. }
  1699. });
  1700. });
  1701. });
  1702. jQuery(document).ready(function() {
  1703. var formfield;
  1704. jQuery('.upload_image_button').click(function() {
  1705. jQuery('html').addClass('Image');
  1706. formfield = jQuery(this).prev().attr('id');
  1707. tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
  1708. return false;
  1709. });
  1710. window.original_send_to_editor = window.send_to_editor;
  1711. window.send_to_editor = function(html){
  1712. if (formfield)
  1713. {
  1714. fileurl = jQuery('img',html).attr('src');
  1715. jQuery('#mr_freeVImage').val(fileurl);
  1716. tb_remove();
  1717. jQuery('html').removeClass('Image');
  1718. }
  1719. else {
  1720. window.original_send_to_editor(html);
  1721. }
  1722. };
  1723. });
  1724. jQuery(document).ready(function() {
  1725. var formfield;
  1726. jQuery('.upload_image_button_g').click(function() {
  1727. jQuery('html').addClass('Image');
  1728. formfield = jQuery(this).prev().attr('id');
  1729. tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
  1730. return false;
  1731. });
  1732. window.original_send_to_editor = window.send_to_editor;
  1733. window.send_to_editor = function(html){
  1734. if (formfield)
  1735. {
  1736. fileurl = jQuery('img',html).attr('src');
  1737. jQuery('#mr_freeGImage').val(fileurl);
  1738. tb_remove();
  1739. jQuery('html').removeClass('Image');
  1740. }
  1741. else {
  1742. window.original_send_to_editor(html);
  1743. }
  1744. };
  1745. }); jQuery(document).ready(function() { var formfield; jQuery('.upload_image_button_d').click(function() { jQuery('html').addClass('Image'); formfield = jQuery(this).prev().attr('id'); tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true'); return false; }); window.original_send_to_editor = window.send_to_editor; window.send_to_editor = function(html){ if (formfield) { fileurl = jQuery('img',html).attr('src'); jQuery('#mr_discount_Image').val(fileurl); tb_remove(); jQuery('html').removeClass('Image'); } else { window.original_send_to_editor(html); } }; });
  1746. </script>
  1747. <style type="text/css">
  1748. .mr-add-video-secOut input[type="text"] {
  1749. width: 70%;
  1750. }
  1751. #free-GVLR-containt th { background: #000 none repeat scroll 0 0; border: 1px solid #444; color: #fff; padding: 5px;
  1752. text-align: start;}
  1753. #free-GVLR-containt td {padding: 5px; border: 1px solid #444; }
  1754. .free-gallery-video-out{margin-top:40px;}
  1755. .video-succ-mess{text-algin:center; color:green;}
  1756. .attachment-thumbnail.wp-post-image {
  1757. height: 50px;
  1758. width: 60px !important;
  1759. }
  1760. </style>
  1761. <div style="text-algin:center;color:green;" id="video-succ-mess"></div>
  1762. <div class="mr-add-video-secOut">
  1763. <form method="post" id="freeVideofrm">
  1764. <table width="75%" >
  1765. <tr>
  1766. <td widget="150px">Free Video title</td>
  1767. <td><input type="text" name="mr_freeVideoTitle" id="mr_freeVideoTitle"></td>
  1768. </tr>
  1769. <tr style="display:none;">
  1770. <td>Free Video url</td><td><input type="text" name="mr_freeVideoUrl" id="mr_freeVideoUrl"></td>
  1771. </tr>
  1772. <tr>
  1773. <td valign="top">Video Image</td>
  1774. <td>
  1775. <input type="text" id="mr_freeVImage" name="mr_freeVImage" placeholder="Enter thumbnail url" style="float:left;" value="">
  1776. <input id="btn_1" class="button-primary upload_image_button" type="button" value="Upload Image" style="width:100px;float:left;" />
  1777. </td>
  1778. </tr>
  1779. <tr>
  1780. <td>Model</td>
  1781. <td>
  1782. <select name="mr_freeVideoModel" id="mr_freeVideoModel">
  1783. <option value="">Select</option>
  1784. <?php
  1785. $args = array('post_type' => 'model',
  1786. 'post_status' => 'publish',
  1787. 'orderby' => 'post_title',
  1788. 'order' => 'ASC',
  1789. 'posts_per_page' => -1);
  1790. $my_query = null;
  1791. $my_query = new WP_Query($args);
  1792. if( $my_query->have_posts() )
  1793. {
  1794. while ($my_query->have_posts()) : $my_query->the_post();
  1795. $mdoel_id = get_the_ID();
  1796. echo '<option value="'.$mdoel_id.'">'.get_the_title().'</option>';
  1797. endwhile;
  1798. }
  1799. wp_reset_query();
  1800. ?>
  1801. </select>
  1802. </td>
  1803. </tr> <tr> <td>Model#2</td> <td> <select name="mr_freeVideoModel_2" id="mr_freeVideoModel_2"> <option value="">Select</option> <?php $mr_ModelId =get_post_meta($mrpostParent,"mr_freeV_model",true); $args = array('post_type' => 'model','post_status' => 'publish','orderby' => 'post_title','order' => 'ASC','posts_per_page' => -1); $my_query = null; $my_query = new WP_Query($args); if($my_query->have_posts()) { while($my_query->have_posts()) : $my_query->the_post(); $model_id = get_the_ID(); ?> <option <?php if($mr_ModelId==$model_id){echo "selected"; }?> value="<?php echo $model_id; ?>"><?php echo get_the_title(); ?></option> <?php endwhile; } wp_reset_query(); ?> </select> </td> </tr> <tr> <td>Video Content</td><td><textarea id="video_content" size="25" name="video_content" ></textarea></td> </tr>
  1804. <tr><td colspan="2">&nbsp;</td></tr>
  1805. <tr>
  1806. <td align="center">
  1807. <input type="button" name="add_fV_Submit_reset" id="add_fV_Submit_reset" value="Clear" class="button button-primary button-large">
  1808. </td>
  1809. <td align="center">
  1810. <input type="button" name="add_freeVideoSubmit" id="add_freeVideoSubmit" value="Add Video" class="button button-primary button-large">
  1811. </td>
  1812. </tr>
  1813. </table>
  1814. </form>
  1815. </div><hr>
  1816. <div class="free-video-list-out">
  1817. <?php
  1818. if(isset($_REQUEST['delFVpostId']))
  1819. {
  1820. $delFVpostId = $_REQUEST['delFVpostId'];
  1821. $fVppdel_succ = wp_delete_post($delFVpostId,true);
  1822. if($fVppdel_succ)
  1823. {
  1824. echo "<h2 class='suss-mess'>Gallery Delete successfully.</h2>";
  1825. ?>
  1826. <script type="text/javascript">
  1827. window.location="<?php echo '?post='.$post->ID.'&action=edit'; ?>";
  1828. </script>
  1829. <?php
  1830. }
  1831. }
  1832. $listFVpost =$wpdb->get_results("select * from $postTab where post_type='freevideo' and post_status='publish' and post_parent='$post->ID' order by ID DESC limit 0,15");
  1833. ?>
  1834. <div id="free-GVLR-containt">
  1835. <table width="70%" border="1" cellpadding="0" cellspacing="0">
  1836. <thead>
  1837. <tr><th>Video Image</th><th>Video Title</th><th>Model</th><th>Model#2</th><th width="100px">Option</th></tr>
  1838. </thead>
  1839. <tbody>
  1840. <?php
  1841. if($listFVpost && $wpdb->num_rows>0)
  1842. {
  1843. foreach($listFVpost as $res)
  1844. {
  1845. $videoThum = get_the_post_thumbnail($res->ID,"thumbnail");
  1846. ?>
  1847. <tr>
  1848. <td><?php echo $videoThum; ?></td>
  1849. <td><?php echo $res->post_title; ?></td>
  1850. <td><?php
  1851. $modelId = get_post_meta($res->ID,'mr_freeV_model',true);
  1852. $modeldetail_Data = get_post($modelId);
  1853. $modelName = $modeldetail_Data->post_title;
  1854. echo $modelName;
  1855. ?></td> <td><?php $modelId = get_post_meta($res->ID,'mr_freeV_model2',true); $modeldetail_Data = get_post($modelId); $modelName = $modeldetail_Data->post_title; echo $modelName; ?></td>
  1856. <td width="">
  1857. <a class="button button-primary button-small" href="<?php echo get_edit_post_link($res->ID); ?>" target="_blank">Edit</a>
  1858. <a class="button button-primary button-small" onclick="return confirm('Are you sure want to delete ?')"
  1859. href="?post=<?php echo $post->ID; ?>&action=edit&delFVpostId=<?php echo $res->ID; ?>">Delete</a>
  1860. </td>
  1861. </tr>
  1862. <?php
  1863. }
  1864. }
  1865. else{
  1866. ?><tr><td colspan="5" align="center"><font color="red">No records</font></td></tr><?php
  1867. }
  1868. ?>
  1869. <tbody>
  1870. </table>
  1871. </div>
  1872. </div>
  1873. <?php
  1874. }
  1875. /* INCLUDE PAGINATION FUNCTION */
  1876. require_once("dz_pagination_function.php");
  1877. /**
  1878. * Disable the emoji's
  1879. */
  1880. function disable_emojis() {
  1881. remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
  1882. remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
  1883. remove_action( 'wp_print_styles', 'print_emoji_styles' );
  1884. remove_action( 'admin_print_styles', 'print_emoji_styles' );
  1885. remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
  1886. remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
  1887. remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
  1888. add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
  1889. }
  1890. add_action( 'init', 'disable_emojis' );
  1891. /**
  1892. * Filter function used to remove the tinymce emoji plugin.
  1893. *
  1894. * @param array $plugins
  1895. * @return array Difference betwen the two arrays
  1896. */
  1897. function disable_emojis_tinymce( $plugins ) {
  1898. if ( is_array( $plugins ) ) {
  1899. return array_diff( $plugins, array( 'wpemoji' ) );
  1900. } else {
  1901. return array();
  1902. }
  1903. }
  1904. /* DISABLE GENERICONS */
  1905. function dequeue_my_css() {
  1906. wp_dequeue_style('genericons');
  1907. wp_deregister_style('genericons');
  1908. }
  1909. add_action('wp_enqueue_scripts','dequeue_my_css', 100);
  1910. /* PAGESPEED webphp */
  1911. /* REMOVE ADMIN BAR */
  1912. //show_admin_bar(false);
  1913. //add_filter(‘show_admin_bar’, ‘__return_false’);
  1914. /* PAGESPEED webphp */
  1915. remove_filter('sanitize_title', 'sanitize_title_with_dashes');
  1916. function sanitize_title_with_dots_and_dashes($title) {
  1917. $title = strip_tags($title); $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title); $title = str_replace('%', '', $title);
  1918. $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
  1919. $title = remove_accents($title);
  1920. if (seems_utf8($title)) {
  1921. if (function_exists('mb_strtolower')) {
  1922. $title = mb_strtolower($title, 'UTF-8');
  1923. }
  1924. $title = utf8_uri_encode($title);
  1925. }
  1926. $title = strtolower($title);
  1927. $title = preg_replace('/&.+?;/', '', $title); // kill entities
  1928. $title = preg_replace('/[^%a-z0-9 ._-]/', '', $title);
  1929. $title = preg_replace('/\s+/', '-', $title);
  1930. $title = preg_replace('|-+|', '-', $title);
  1931. $title = trim($title, '-');
  1932. $title = str_replace('-.-', '.', $title);
  1933. $title = str_replace('-.', '.', $title);
  1934. $title = str_replace('.-', '.', $title);
  1935. $title = preg_replace('|([^.])\.$|', '$1', $title);
  1936. $title = trim($title, '-');
  1937. return $title;
  1938. }
  1939. add_filter('sanitize_title', 'sanitize_title_with_dots_and_dashes');
  1940. add_theme_support( 'post-thumbnails', array( 'post', 'portfolio-items', 'slider-items', 'testimonial-items', ) );
  1941. add_image_size( 'slider-larger', 958, 460 );
  1942. add_image_size( 'slider-thumb', 195, 90 );
  1943. add_image_size( 'portfolio-thumb', 220, 180 );
  1944. add_image_size( 'author-thumb', 200, 200 );
  1945. add_image_size( 'freeGallery', 240, 360 );
  1946. add_image_size( 'galleryhover', 240, 360, true );
  1947. add_image_size( 'galleryhome', 123, 183, true );
  1948. add_image_size( 'bornstarshome', 152, 229, true );
  1949. //add_image_size( 'videoshome', 198, 111, true );
  1950. add_image_size( 'videoshome', 415, 233, true );
  1951. add_image_size( 'gallerypage', 215, 321, true );
  1952. /**
  1953. * Extend WordPress search to include custom fields
  1954. *
  1955. * http://adambalee.com
  1956. */
  1957. /**
  1958. * Join posts and postmeta tables
  1959. *
  1960. * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join
  1961. */
  1962. function cf_search_join( $join ) {
  1963. global $wpdb;
  1964. if ( is_search() ) {
  1965. $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
  1966. }
  1967. return $join;
  1968. }
  1969. add_filter('posts_join', 'cf_search_join' );
  1970. /**
  1971. * Modify the search query with posts_where
  1972. *
  1973. * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where
  1974. */
  1975. function cf_search_where( $where ) {
  1976. global $pagenow, $wpdb;
  1977. if ( is_search() ) {
  1978. $where = preg_replace(
  1979. "/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
  1980. "(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );
  1981. }
  1982. return $where;
  1983. }
  1984. add_filter( 'posts_where', 'cf_search_where' );
  1985. /**
  1986. * Prevent duplicates
  1987. *
  1988. * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_distinct
  1989. */
  1990. function cf_search_distinct( $where ) {
  1991. global $wpdb;
  1992. if ( is_search() ) {
  1993. return "DISTINCT";
  1994. }
  1995. return $where;
  1996. }
  1997. add_filter( 'posts_distinct', 'cf_search_distinct' );
  1998. function wpb_set_post_views($postID) {
  1999. $count_key = 'wpb_post_views_count';
  2000. $count = get_post_meta($postID, $count_key, true);
  2001. if($count==''){
  2002. $count = 0;
  2003. delete_post_meta($postID, $count_key);
  2004. add_post_meta($postID, $count_key, '0');
  2005. }else{
  2006. $count++;
  2007. update_post_meta($postID, $count_key, $count);
  2008. }}
  2009. function wpb_track_post_views ($post_id) {
  2010. if ( !is_single() ) return;
  2011. if ( empty ( $post_id) ) {
  2012. global $post;
  2013. $post_id = $post->ID;
  2014. }
  2015. wpb_set_post_views($post_id);}
  2016. add_action( 'wp_head', 'wpb_track_post_views');
  2017. function wpb_get_post_views($postID){ $count_key = 'wpb_post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' Views';}
  2018. add_filter( 'posts_where', 'title_like_posts_where', 10, 2 );
  2019. function title_like_posts_where( $where, &$wp_query ) {
  2020. global $wpdb;
  2021. if ( $post_title_like = $wp_query->get( 'post_title_like' ) ) {
  2022. $where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'' . esc_sql( $wpdb->esc_like( $post_title_like ) ) . '%\''; }
  2023. return $where;
  2024. }
  2025. add_action('wp_enqueue_scripts', 'se_wp_enqueue_scripts');
  2026. function se_wp_enqueue_scripts() {
  2027. wp_enqueue_script('suggest');
  2028. }
  2029. add_action('wp_head', 'se_wp_head');
  2030. function se_wp_head() {
  2031. ?>
  2032. <script type="text/javascript">
  2033. var se_ajax_url = '<?php echo admin_url('admin-ajax.php'); ?>';
  2034. jQuery(document).ready(function() {
  2035. jQuery('#search-input').suggest(se_ajax_url + '?action=se_lookup');
  2036. });
  2037. </script>
  2038. <style>
  2039. .ac_results > li {
  2040. padding: 5px 20px;
  2041. }
  2042. .ac_results {
  2043. background: #fff none repeat scroll 0 0;
  2044. color: #000;
  2045. max-width: 300px;
  2046. position: absolute !important;
  2047. width: 80%;
  2048. z-index: 2147483647;
  2049. padding:0;
  2050. }
  2051. .ac_results > li:hover {
  2052. background: #981d67 none repeat scroll 0 0;
  2053. color: #fff;
  2054. }
  2055. </style>
  2056. <?php
  2057. }
  2058. add_action('wp_ajax_se_lookup', 'se_lookup');
  2059. add_action('wp_ajax_nopriv_se_lookup', 'se_lookup');
  2060. function se_lookup() {
  2061. global $wpdb;
  2062. $postTab = $wpdb->prefix."posts";
  2063. $postMeta = $wpdb->prefix."postmeta";
  2064. $search = like_escape($_REQUEST['q']);
  2065. $query = 'SELECT ID,post_title FROM ' . $wpdb->posts . '
  2066. WHERE post_title LIKE \'%' . $search . '%\'
  2067. AND post_type = \'model\'
  2068. AND post_status = \'publish\'
  2069. ORDER BY post_title ASC';
  2070. foreach ($wpdb->get_results($query) as $row) {
  2071. $post_title = $row->post_title;
  2072. $id = $row->ID;
  2073. echo $post_title. "\n";
  2074. }
  2075. $query1 = "select * from $postTab as a,$postMeta as b where a.ID=b.post_id and a.post_type='model' and a.post_status='publish' and
  2076. b.meta_key='aka' and b.meta_value LIKE \"%" . $search . "%\"
  2077. ORDER BY post_title ASC";
  2078. /* echo $query1; */
  2079. $full_list=array();
  2080. foreach ($wpdb->get_results($query1) as $row1) {
  2081. $post_title = $row1->post_title;
  2082. $id = $row1->ID;
  2083. $meta = get_post_meta($id, 'aka', TRUE);
  2084. $pieces = explode(",", $meta);
  2085. $full_list=array_merge($full_list,$pieces);
  2086. }
  2087. $efull_list=array_unique($full_list);
  2088. $arrlength = count($efull_list);
  2089. for($x = 0; $x < $arrlength; $x++) {
  2090. if (preg_match('/'.$search.'/i',$efull_list[$x])){
  2091. echo $efull_list[$x]. "\n";
  2092. }
  2093. }
  2094. die();
  2095. }
  2096. function mytheme_comment($comment, $args, $depth) {
  2097. $GLOBALS['comment'] = $comment;
  2098. if($depth>1)
  2099. { ?>
  2100. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  2101. <div id="comment-<?php comment_ID(); ?>">
  2102. <div class="comment-author vcard reply_com">
  2103. <?php /* echo get_avatar($comment,$size='48',$default='<path_to_url>' ); */ ?>
  2104. <?php printf(__('<strong class="fn"><span class="says">Reply From </span>%s</strong>'), get_comment_author_link()) ?>
  2105. <?php printf(__('(Date: %1$s): '), get_comment_date()) ?>
  2106. </div>
  2107. <?php if ($comment->comment_approved == '0') : ?>
  2108. <em><?php _e('Your comment is awaiting moderation.') ?></em>
  2109. <br />
  2110. <?php endif; ?>
  2111. <?php comment_text() ?>
  2112. </div>
  2113. </li>
  2114. <?php
  2115. }
  2116. else{ ?>
  2117. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  2118. <div id="comment-<?php comment_ID(); ?>">
  2119. <div class="comment-author vcard ">
  2120. <?php /* echo get_avatar($comment,$size='48',$default='<path_to_url>' ); */ ?>
  2121. <?php printf(__('<span class="says">Comment by: </span><strong class="fn">%s</strong>'), get_comment_author_link()) ?>
  2122. </div>
  2123. <?php if ($comment->comment_approved == '0') : ?>
  2124. <em><?php _e('Your comment is awaiting moderation.') ?></em>
  2125. <br />
  2126. <?php endif; ?>
  2127. <div class="comment-meta commentmetadata">
  2128. <?php $scores=get_comment_meta( $comment->comment_ID, 'score', $single = false );
  2129. echo 'Score: <span class="blue_box">'.$scores[0]."</span>";
  2130. ?>
  2131. <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('Date: %1$s'), get_comment_date()) ?></a><?php edit_comment_link(__('(Edit)'),' ','') ?></div>
  2132. <?php comment_text() ?>
  2133. <?php if ( current_user_can( 'manage_options' ) ) { ?>
  2134. <div class="reply1">
  2135. <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  2136. </div>
  2137. <?php } ?>
  2138. </div>
  2139. </li>
  2140. <?php
  2141. }
  2142. }
  2143. add_action( 'comment_form_logged_in_after', 'additional_fields' );
  2144. add_action( 'comment_form_after_fields', 'additional_fields' );
  2145. function additional_fields () {
  2146. if(isset($_GET['replytocom'])){
  2147. }
  2148. else{
  2149. echo '<p style="color:red;display:none;" id="required_com">*All fields are required</p><p class="small_content">* Please include a pro and a con about the site.Balance is essential in making a comment worthwhile<br />* Watch out the ratings of zero and 100.In our opinion, there is no such thing as a site that is absolutely perfect and completely worthless.</p><p class="comment-form-score">'.
  2150. /*'<label for="Score">'. __('Score') . '<span class="required">*</span></label>*/
  2151. ' <fieldset><div class="perDrop"><select id="select_score" name="score" required><option value="">Select Score</option> ';
  2152. $i=0;
  2153. while( $i <= 100 ){
  2154. if($i==0){
  2155. echo '<option id="score" value="1%"/>1%</option>';
  2156. }
  2157. else{
  2158. echo '<option id="score" value="'. $i .'%"/>'. $i .'%</option>';
  2159. }
  2160. $i=$i+10;
  2161. }
  2162. echo'</select></div>';
  2163. if ( is_user_logged_in() ) {
  2164. echo '<input id="com_email" placeholder="Email" name="com_email" type="text" size="30" tabindex="5" required />';
  2165. echo '<input id="agree_check" name="agree_check" type="checkbox" size="30" /><label for="agree_check">' . __( 'I am human' ) . '</label></fieldset>';
  2166. }
  2167. else{
  2168. echo
  2169. '<input id="agree_check" name="agree_check" type="checkbox" size="30" /><label for="agree_check">' . __( 'I am human' ) . '</label></fieldset>';
  2170. }
  2171. }
  2172. }
  2173. add_action('comment_post', 'save_comment_meta_data', 10, 2);
  2174. function save_comment_meta_data( $comment_id ) {
  2175. ;
  2176. if ( ( isset( $_POST['com_email'] ) ) && ( $_POST['com_email'] != '') ){
  2177. $com_email = wp_filter_nohtml_kses($_POST['com_email']);
  2178. add_comment_meta( $comment_id, 'com_email', $com_email );
  2179. }
  2180. if ( ( isset( $_POST['score'] ) ) && ( $_POST['score'] != '') ){
  2181. $score = wp_filter_nohtml_kses($_POST['score']);
  2182. add_comment_meta( $comment_id, 'score', $score );
  2183. }
  2184. }
  2185. add_filter( 'preprocess_comment', 'verify_comment_meta_data' );
  2186. function verify_comment_meta_data( $commentdata ) {
  2187. if ( ( !isset( $_POST['score'] ) ) || ( $_POST['score'] == '') ){
  2188. wp_die( __( 'Error: You did not add a Score. Hit the Back button on your Web browser and resubmit your comment with a Score.' ) );
  2189. }
  2190. if ( ( !isset( $_POST['agree_check'] ) ) || ( $_POST['agree_check'] == '') ){
  2191. wp_die( __( 'Error: Please check I am human. Hit the Back button on your Web browser and resubmit your comment by checking I am human.' ) );
  2192. }
  2193. return $commentdata;
  2194. }
  2195. /*
  2196. function wpb_move_comment_field_to_bottom( $fields ) {
  2197. $comment_field = $fields['comment'];
  2198. unset( $fields['comment'] );
  2199. $fields['comment'] = $comment_field;
  2200. return $fields;
  2201. }
  2202. add_filter( 'comment_form_fields', 'wpb_move_comment_field_to_bottom' ); */
  2203. //excerpt limit
  2204. function excerpt($num) {
  2205. $limit = $num+1;
  2206. $excerpt = explode(' ', get_the_excerpt(), $limit);
  2207. array_pop($excerpt);
  2208. $excerpt = implode(" ",$excerpt)."...";
  2209. echo $excerpt;
  2210. }
  2211. //enable comment all
  2212. function discount_price($post){ ?>
  2213. <table width="100%" >
  2214. <tr>
  2215. <td>Show category ID</td>
  2216. <td>
  2217. <input type="text" name="show_cat1" id="show_cat1" value="<?php echo get_post_meta($post->ID,"show_cat1",true); ?>">
  2218. </td>
  2219. <td>
  2220. <input type="text" name="show_cat2" id="show_cat2" value="<?php echo get_post_meta($post->ID,"show_cat2",true); ?>">
  2221. </td>
  2222. <td>
  2223. <input type="text" name="show_cat3" id="show_cat3" value="<?php echo get_post_meta($post->ID,"show_cat3",true); ?>">
  2224. </td>
  2225. <td>
  2226. <input type="text" name="show_cat4" id="show_cat4" value="<?php echo get_post_meta($post->ID,"show_cat4",true); ?>">
  2227. </td>
  2228. </tr>
  2229. </table>
  2230. <?php }
  2231. add_action( 'add_meta_boxes', 'property_area' );
  2232. function property_area()
  2233. {
  2234. add_meta_box('pr-details-section','Show category','discount_price','page', 'normal', 'high');
  2235. }
  2236. add_action('save_post', 'save_property_data');
  2237. function save_property_data(){
  2238. global $post;
  2239. if($post->post_type == 'page')
  2240. {
  2241. update_post_meta($post->ID, 'show_cat1', $_POST['show_cat1']);
  2242. update_post_meta($post->ID, 'show_cat2', $_POST['show_cat2']);
  2243. update_post_meta($post->ID, 'show_cat3', $_POST['show_cat3']);
  2244. update_post_meta($post->ID, 'show_cat4', $_POST['show_cat4']);
  2245. }
  2246. }
  2247. function today_offer($post){
  2248. ?><table width="20%"style="margin-bottom:30px;" >
  2249. <tr>
  2250. <?php $active_discount=get_post_meta ($post->ID,"today_offer",true); ?>
  2251. <td>Add to today offer</td>
  2252. <td><input type="checkbox" name="today_offer" id="today_offer" value="offer"<?php if($active_discount=='offer'){ echo "checked"; }?> ></td>
  2253. </td>
  2254. </tr>
  2255. </table>
  2256. <?php }
  2257. function search_script_footer(){ ?>
  2258. <script type="text/javascript">
  2259. jQuery(document).ready(function(){
  2260. jQuery("#search_result").hide();
  2261. jQuery('#search-box-header').keyup(function(){
  2262. var value= jQuery(this).val();
  2263. var filter= jQuery('#filter-search').val();
  2264. var length=jQuery(this).val().length;
  2265. if(length>3){
  2266. jQuery.ajax({
  2267. url: "<?php echo get_template_directory_uri();?>/custom_search.php",
  2268. method: "POST",
  2269. data: {search_v:value,filter:filter},
  2270. success: function(mr_result)
  2271. {
  2272. jQuery("#search_result").html(mr_result);
  2273. jQuery("#search_result").show();
  2274. }
  2275. });
  2276. }
  2277. else{
  2278. jQuery("#search_result").hide();
  2279. }
  2280. });
  2281. jQuery('#searchTypes .all').click(function(){
  2282. jQuery('#search_form').attr('action','https://bestborn.com');
  2283. jQuery('#searchTypeSelected i').attr('class','all');
  2284. jQuery('#search-box-header').attr('name','s');
  2285. jQuery('#filter-search').val('all');
  2286. jQuery('#searchTypes').hide();
  2287. });
  2288. jQuery('#searchTypes .review').click(function(){
  2289. jQuery('#search_form').attr('action','https://bestborn.com/latest-reviews');
  2290. jQuery('#searchTypeSelected i').attr('class','review');
  2291. jQuery('#search-box-header').attr('name','search');
  2292. jQuery('#filter-search').val('review');
  2293. jQuery('#searchTypes').hide();
  2294. });
  2295. jQuery('#searchTypes .video').click(function(){
  2296. jQuery('#search_form').attr('action','https://bestborn.com/videos');
  2297. jQuery('#searchTypeSelected i').attr('class','video');
  2298. jQuery('#search-box-header').attr('name','search');
  2299. jQuery('#filter-search').val('video');
  2300. jQuery('#searchTypes').hide();
  2301. });
  2302. jQuery('#searchTypes .bornstars').click(function(){
  2303. jQuery('#search_form').attr('action','https://bestborn.com/bornstars');
  2304. jQuery('#searchTypeSelected i').attr('class','bornstars');
  2305. jQuery('#search-box-header').attr('name','search');
  2306. jQuery('#filter-search').val('bornstars');
  2307. jQuery('#searchTypes').hide();
  2308. });
  2309. jQuery('#searchTypes .photos').click(function(){
  2310. jQuery('#search_form').attr('action','https://bestborn.com/galleries');
  2311. jQuery('#searchTypeSelected i').attr('class','photos');
  2312. jQuery('#search-box-header').attr('name','search');
  2313. jQuery('#filter-search').val('photos');
  2314. jQuery('#searchTypes').hide();
  2315. });
  2316. jQuery('#searchTypes .discounts').click(function(){
  2317. jQuery('#search_form').attr('action','https://bestborn.com/discounts');
  2318. jQuery('#searchTypeSelected i').attr('class','discounts');
  2319. jQuery('#search-box-header').attr('name','search');
  2320. jQuery('#filter-search').val('discounts');
  2321. jQuery('#searchTypes').hide();
  2322. });
  2323. jQuery('#searchTypes .blog').click(function(){
  2324. jQuery('#search_form').attr('action','https://bestborn.com/blog');
  2325. jQuery('#searchTypeSelected i').attr('class','blog');
  2326. jQuery('#search-box-header').attr('name','search');
  2327. jQuery('#filter-search').val('blog');
  2328. jQuery('#searchTypes').hide();
  2329. });
  2330. jQuery('#searchTypeSelected').click(function(){
  2331. jQuery('#searchTypes').toggle();
  2332. });
  2333. jQuery( "body" ).on( "click", ".show_more", function() {
  2334. var action=jQuery(this).attr('action-data');
  2335. jQuery('#search-box-header').attr('name','search');
  2336. jQuery('#search_form').attr('action','https://bestborn.com/'+action);
  2337. jQuery("#search_form").submit();
  2338. });
  2339. });
  2340. </script>
  2341. <?php }
  2342. add_action('wp_footer', 'search_script_footer',100 );
  2343. function title_filter( $where, &$wp_query )
  2344. {
  2345. global $wpdb;
  2346. if ( $search_term = $wp_query->get( 'search_prod_title' ) ) {
  2347. $where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'%' . esc_sql( like_escape( $search_term ) ) . '%\'';
  2348. }
  2349. return $where;
  2350. }
  2351. add_filter( 'posts_where', 'title_filter', 10, 2 );
  2352. function video_ecxep($post){ ?>
  2353. <table width="100%" >
  2354. <tr>
  2355. <td>
  2356. <textarea name="video_exc" id="show_cat1" value="<?php echo get_post_meta($post->ID,"video_exc",true); ?>"style="width:100%;"></textarea>
  2357. </td>
  2358. </tr>
  2359. </table>
  2360. <?php }
  2361. add_action( 'add_meta_boxes', 'property_area8' );
  2362. function property_area8()
  2363. {
  2364. add_meta_box('pr-details-section','Excerpt','video_ecxep','freevideo', 'normal', 'high');
  2365. }
  2366. add_action('save_post', 'save_property_data8');
  2367. function save_property_data8(){
  2368. global $post;
  2369. if($post->post_type == 'freevideo')
  2370. {
  2371. update_post_meta($post->ID, 'video_exc', $_POST['video_exc']);
  2372. }
  2373. }
  2374. /*
  2375. * Creating a function to create our CPT
  2376. */
  2377. function register_cgif() {
  2378. $labels = array(
  2379. 'name' =>'Gifs',
  2380. 'singular_name' =>'Gif',
  2381. 'menu_name' =>'Gifs',
  2382. 'name_admin_bar' =>'Gifs',
  2383. 'add_new' =>'Add New',
  2384. 'add_new_item' =>'Add New GIF',
  2385. 'new_item' =>'New GIF',
  2386. 'edit_item' =>'Edit Gif',
  2387. 'view_item' =>'View Gif',
  2388. 'all_items' =>'All Gif',
  2389. 'search_items' =>'Search Gif',
  2390. 'parent_item_colon' =>'Parent Gif',
  2391. 'not_found' =>'No Models found.',
  2392. 'not_found_in_trash' =>'No Models found in Trash.'
  2393. );
  2394. $args = array(
  2395. 'labels' => $labels,
  2396. 'description' =>'Description.',
  2397. 'public' => true,
  2398. 'publicly_queryable' => true,
  2399. 'show_ui' => true,
  2400. 'show_in_menu' => true,
  2401. 'query_var' => true,
  2402. 'rewrite' => array( 'slug' => 'gif', 'with_front' => FALSE ),
  2403. 'capability_type' => 'post',
  2404. 'has_archive' => true,
  2405. 'hierarchical' => false,
  2406. 'menu_position' => 8,
  2407. 'supports' => array( 'title','thumbnail','editor','comments')
  2408. );
  2409. register_post_type( 'gif', $args );
  2410. }
  2411. add_action( 'init', 'register_cgif');
  2412. function custom_rating_image_extension() {
  2413. return 'png';
  2414. }
  2415. add_filter( 'wp_postratings_image_extension', 'custom_rating_image_extension' );
  2416. function filter_plugin_updates( $value ) {
  2417. unset( $value->response['wp-postratings/wp-postratings.php'] );
  2418. return $value;
  2419. }
  2420. add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
  2421. function create_posttypes() {
  2422. register_post_type( 'modelsuggestion',
  2423. // CPT Options
  2424. array(
  2425. 'labels' => array(
  2426. 'name' => __( 'Model Suggestions ' ),
  2427. 'singular_name' => __( 'suggestion' )
  2428. ),
  2429. 'public' => true,
  2430. 'rewrite' => array('slug' => 'suggestion'),
  2431. 'supports' => array('title','thumbnail','revisions')
  2432. )
  2433. );
  2434. }
  2435. add_action('wp_login', 'set_last_login');
  2436. function set_last_login($login) {
  2437. $user = get_userdatabylogin($login);
  2438. update_usermeta( $user->ID, 'last_login', current_time('mysql') );
  2439. }
  2440. function get_last_login($user_id) {
  2441. $last_login = get_user_meta($user_id, 'last_login', true);
  2442. $date_format = get_option('date_format') . ' ' . get_option('time_format');
  2443. $the_last_login = mysql2date($date_format, $last_login, false);
  2444. return $the_last_login;
  2445. }
  2446. function bimber_mycred_sort_badges_by_order( $a, $b ) {
  2447. $a = get_post_field( 'menu_order', $a );
  2448. $b = get_post_field( 'menu_order', $b );
  2449. if ( $a == $b ) {
  2450. return 0;
  2451. }
  2452. return ( $a < $b ) ? -1 : 1;
  2453. }
  2454. ?>
Comments powered by Disqus