Code Duplication    Length = 21-24 lines in 3 locations

classes/wordpress.php 3 locations

@@ 572-592 (lines=21) @@
569
			case 'comment':
570
				$result = $this->comment_create( $params, $id_field );
571
				break;
572
			default:
573
				/*
574
				 * Developers can use this hook to create objects with their own methods.
575
				 * The returned $result needs to be an array like this.
576
				 * $id_field should be the database key; i.e. 'ID' and the value should be the new item's id, or whatever WordPress returns from the method (sometimes this can be an error)
577
				 * $success should be a boolean value
578
					$result = array( 'data' => array( $id_field => $post_id, 'success' => $success ), 'errors' => $errors );
579
				 * use hook like: add_filter( 'object_sync_for_salesforce_create_custom_wordpress_item', add_object, 10, 1 );
580
				 * the one param is: array( 'name' => objecttype, 'params' => array_of_params, 'id_field' => idfield )
581
				 */
582
				// Check to see if someone is calling the filter, and apply it if so.
583
				if ( ! has_filter( $this->option_prefix . 'create_custom_wordpress_item' ) ) {
584
					$result = $this->post_create( $params, $id_field, $name );
585
				} else {
586
					$result = apply_filters( $this->option_prefix . 'create_custom_wordpress_item', array(
587
						'params'   => $params,
588
						'name'     => $name,
589
						'id_field' => $id_field,
590
					) );
591
				}
592
				break;
593
		} // End switch().
594
595
		return $result;
@@ 733-756 (lines=24) @@
730
			case 'comment':
731
				$result = $this->comment_update( $id, $params, $id_field );
732
				break;
733
			default:
734
				/*
735
				 * Developers can use this hook to update objects with their own methods.
736
				 * The returned $result needs to be an array like this:
737
				 *     $id_field should be the database key; i.e. 'ID' and the value should be the updated item's id, or whatever WordPress returns from the method (sometimes this can be an error)
738
				 * $success should be a boolean value
739
				 *     $result = array( 'data' => array( $id_field => $post_id, 'success' => $success ), 'errors' => $errors );
740
				 * Use hook like this:
741
				 *     add_filter( 'object_sync_for_salesforce_update_custom_wordpress_item', update_object, 10, 1 );
742
				 * The one param is:
743
				 *     array( 'id' => id, 'params' => array_of_params, 'name' => objecttype, 'id_field' => idfield )
744
				 */
745
				// Check to see if someone is calling the filter, and apply it if so.
746
				if ( ! has_filter( $this->option_prefix . 'update_custom_wordpress_item' ) ) {
747
					$result = $this->post_update( $id, $params, $id_field, $name );
748
				} else {
749
					$result = apply_filters( $this->option_prefix . 'update_custom_wordpress_item', array(
750
						'id'       => $id,
751
						'params'   => $params,
752
						'name'     => $name,
753
						'id_field' => $id_field,
754
					) );
755
				}
756
				break;
757
		} // End switch().
758
759
		return $result;
@@ 797-817 (lines=21) @@
794
			case 'comment':
795
				$success = $this->comment_delete( $id );
796
				break;
797
			default:
798
				/*
799
				 * Developers can use this hook to delete objects with their own methods.
800
				 * The returned $success is an object of the correct type, or a FALSE
801
				 * Use hook like:
802
				 *     add_filter( 'object_sync_for_salesforce_delete_custom_wordpress_item', delete_object, 10, 1 );
803
				 * The one param is:
804
				 *     array( 'id' => id, 'name' => objecttype )
805
				 */
806
				// Check to see if someone is calling the filter, and apply it if so.
807
				if ( ! has_filter( $this->option_prefix . 'delete_custom_wordpress_item' ) ) {
808
					$success = $this->post_delete( $id );
809
				} else {
810
					$success = apply_filters( $this->option_prefix . 'delete_custom_wordpress_item', array(
811
						'id'   => $id,
812
						'name' => $name,
813
					) );
814
				}
815
816
				$success = $this->post_delete( $id );
817
				break;
818
		} // End switch().
819
820
		$result = array(