Code Duplication    Length = 31-33 lines in 3 locations

components/Helpers.php 1 location

@@ 320-350 (lines=31) @@
317
     *
318
     * @return bool|int|null
319
     */
320
    public function save_meta ( $_null, $post_ID = null, $meta_key = null, $meta_value = null ) {
321
        if ( 'code' == $meta_key ) {
322
            $post = get_post( $post_ID );
323
324
            if ( is_object( $post ) && $this->object_type == $post->post_type ) {
325
                $postdata = array(
326
                    'ID' => $post_ID,
327
                    'post_content' => $meta_value
328
                );
329
330
                remove_filter( current_filter(), array( $this, __FUNCTION__ ) );
331
332
                $revisions = false;
333
334
                if ( has_action( 'pre_post_update', 'wp_save_post_revision' ) ) {
335
                    remove_action( 'pre_post_update', 'wp_save_post_revision' );
336
337
                    $revisions = true;
338
                }
339
340
                wp_update_post( (object) $postdata ); // objects will be automatically sanitized
341
342
                if ( $revisions )
343
                    add_action( 'pre_post_update', 'wp_save_post_revision' );
344
345
                return true;
346
            }
347
        }
348
349
        return $_null;
350
    }
351
352
    /**
353
     * @static

components/Pages.php 1 location

@@ 644-676 (lines=33) @@
641
	 *
642
	 * @return bool|int|null
643
	 */
644
	public function save_meta( $_null, $post_ID = null, $meta_key = null, $meta_value = null ) {
645
646
		if ( 'code' === $meta_key ) {
647
			$post = get_post( $post_ID );
648
649
			if ( is_object( $post ) && $this->object_type == $post->post_type ) {
650
				$postdata = array(
651
					'ID'           => $post_ID,
652
					'post_content' => $meta_value,
653
				);
654
655
				remove_filter( current_filter(), array( $this, __FUNCTION__ ) );
656
657
				$revisions = false;
658
659
				if ( has_action( 'pre_post_update', 'wp_save_post_revision' ) ) {
660
					remove_action( 'pre_post_update', 'wp_save_post_revision' );
661
662
					$revisions = true;
663
				}
664
665
				wp_update_post( (object) $postdata );
666
				// objects will be automatically sanitized
667
				if ( $revisions ) {
668
					add_action( 'pre_post_update', 'wp_save_post_revision' );
669
				}
670
671
				return true;
672
			}//end if
673
		}//end if
674
675
		return $_null;
676
	}
677
678
	/**
679
	 * Flush Pod Page Rewrite cache

components/Templates/Templates.php 1 location

@@ 437-469 (lines=33) @@
434
	 *
435
	 * @return bool|int|null
436
	 */
437
	public function save_meta( $_null, $post_ID = null, $meta_key = null, $meta_value = null ) {
438
439
		if ( 'code' === $meta_key ) {
440
			$post = get_post( $post_ID );
441
442
			if ( is_object( $post ) && $this->object_type == $post->post_type ) {
443
				$postdata = array(
444
					'ID'           => $post_ID,
445
					'post_content' => $meta_value,
446
				);
447
448
				remove_filter( current_filter(), array( $this, __FUNCTION__ ) );
449
450
				$revisions = false;
451
452
				if ( has_action( 'pre_post_update', 'wp_save_post_revision' ) ) {
453
					remove_action( 'pre_post_update', 'wp_save_post_revision' );
454
455
					$revisions = true;
456
				}
457
458
				wp_update_post( (object) $postdata );
459
				// objects will be automatically sanitized
460
				if ( $revisions ) {
461
					add_action( 'pre_post_update', 'wp_save_post_revision' );
462
				}
463
464
				return true;
465
			}//end if
466
		}//end if
467
468
		return $_null;
469
	}
470
471
	/**
472
	 * Display the page template