@@ -2674,177 +2674,6 @@ public function parse_text( $post, $message ) {
26742674
26752675 }
26762676
2677- /**
2678- * Parses the status' Google Business configuration to return an array of compatible
2679- * arguments that can be used to send the status.
2680- *
2681- * @since 1.0.0
2682- *
2683- * @param WP_Post $post Post.
2684- * @param array $status Status.
2685- * @return bool|array Google Business Profile status configuration
2686- */
2687- public function parse_google_business ( $ post , $ status ) {
2688-
2689- // Bail if no Google Business configuration exists in the status.
2690- if ( ! isset ( $ status ['googlebusiness ' ] ) ) {
2691- return false ;
2692- }
2693- if ( ! is_array ( $ status ['googlebusiness ' ] ) ) {
2694- return false ;
2695- }
2696- if ( ! isset ( $ status ['googlebusiness ' ]['post_type ' ] ) ) {
2697- return false ;
2698- }
2699-
2700- // Start building arguments.
2701- $ google_business_args = array (
2702- 'post_type ' => $ status ['googlebusiness ' ]['post_type ' ],
2703- 'link ' => $ this ->get_permalink ( $ post ),
2704- );
2705-
2706- // Depending on the Google Business Post Type, build arguments.
2707- switch ( $ status ['googlebusiness ' ]['post_type ' ] ) {
2708- case 'offer ' :
2709- case 'event ' :
2710- // Title.
2711- $ google_business_args ['title ' ] = $ this ->parse_text ( $ post , $ status ['googlebusiness ' ]['title ' ] );
2712-
2713- // Code and Terms: Offers.
2714- if ( $ status ['googlebusiness ' ]['post_type ' ] === 'offer ' ) {
2715- $ google_business_args = array_merge (
2716- $ google_business_args ,
2717- array (
2718- 'code ' => $ this ->parse_text ( $ post , $ status ['googlebusiness ' ]['code ' ] ),
2719- 'terms ' => $ this ->parse_text ( $ post , $ status ['googlebusiness ' ]['terms ' ] ),
2720- )
2721- );
2722- } else {
2723- // Event: Button.
2724- $ google_business_args ['cta ' ] = $ status ['googlebusiness ' ]['cta ' ];
2725- }
2726-
2727- // Start Date.
2728- switch ( $ status ['googlebusiness ' ]['start_date_option ' ] ) {
2729- /**
2730- * Custom Post Meta
2731- */
2732- case 'custom ' :
2733- // Fetch the Post's Meta Value based on the given Custom Field Key.
2734- $ date = get_post_meta ( $ post ->ID , $ status ['googlebusiness ' ]['start_date ' ], true );
2735-
2736- // If the post date is numeric, it's most likely a timestamp
2737- // Convert it to a date and time.
2738- if ( is_numeric ( $ date ) ) {
2739- $ date = date ( 'Y-m-d H:i:s ' , $ date ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
2740- }
2741-
2742- // Set start date.
2743- $ google_business_args ['start_date ' ] = strtotime ( $ date );
2744- $ google_business_args ['start_time ' ] = date ( 'H:i ' , strtotime ( $ date ) ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
2745- break ;
2746-
2747- /**
2748- * None
2749- */
2750- case '' :
2751- break ;
2752-
2753- /**
2754- * Third Party integrations
2755- */
2756- default :
2757- $ date = false ;
2758-
2759- /**
2760- * Allows integrations to define the status' start date for a Google Business Profile Offer or Event.
2761- *
2762- * @since 1.0.0
2763- *
2764- * @param bool|string $date Date (yyyy-mm-dd hh:mm:ss format).
2765- * @param array $google_business_args Google Business specific arguments for status.
2766- * @param array $status Status.
2767- * @param WP_Post $post WordPress Post.
2768- */
2769- $ date = apply_filters ( 'social_post_flow_publish_parse_google_business_start_date_ ' . $ status ['googlebusiness ' ]['start_date_option ' ], $ date , $ google_business_args , $ status , $ post );
2770-
2771- // Ignore if no date defined.
2772- if ( ! $ date ) {
2773- break ;
2774- }
2775-
2776- // Set start date.
2777- $ google_business_args ['start_date ' ] = strtotime ( $ date );
2778- $ google_business_args ['start_time ' ] = date ( 'H:i ' , strtotime ( $ date ) ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
2779- break ;
2780- }
2781-
2782- // End Date.
2783- switch ( $ status ['googlebusiness ' ]['end_date_option ' ] ) {
2784- /**
2785- * Custom Post Meta
2786- */
2787- case 'custom ' :
2788- // Fetch the Post's Meta Value based on the given Custom Field Key.
2789- $ date = get_post_meta ( $ post ->ID , $ status ['googlebusiness ' ]['end_date ' ], true );
2790-
2791- // If the post date is numeric, it's most likely a timestamp
2792- // Convert it to a date and time.
2793- if ( is_numeric ( $ date ) ) {
2794- $ date = date ( 'Y-m-d H:i:s ' , $ date ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
2795- }
2796-
2797- // Set end date.
2798- $ google_business_args ['end_date ' ] = strtotime ( $ date );
2799- $ google_business_args ['end_time ' ] = date ( 'H:i ' , strtotime ( $ date ) ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
2800- break ;
2801-
2802- /**
2803- * None
2804- */
2805- case '' :
2806- break ;
2807-
2808- /**
2809- * Third Party integrations
2810- */
2811- default :
2812- $ date = false ;
2813-
2814- /**
2815- * Allows integrations to define the status' end date for a Google Business Profile Offer or Event.
2816- *
2817- * @since 1.0.0
2818- *
2819- * @param bool|string $date Date (yyyy-mm-dd hh:mm:ss format).
2820- * @param array $google_business_args Google Business specific arguments for status.
2821- * @param array $status Status.
2822- * @param WP_Post $post WordPress Post.
2823- */
2824- $ date = apply_filters ( 'social_post_flow_publish_parse_google_business_end_date_ ' . $ status ['googlebusiness ' ]['end_date_option ' ], $ date , $ google_business_args , $ status , $ post );
2825-
2826- // Ignore if no date defined.
2827- if ( ! $ date ) {
2828- break ;
2829- }
2830-
2831- // Set end date.
2832- $ google_business_args ['end_date ' ] = strtotime ( $ date );
2833- $ google_business_args ['end_time ' ] = date ( 'H:i ' , strtotime ( $ date ) ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
2834- break ;
2835- }
2836- break ;
2837-
2838- case 'whats_new ' :
2839- default :
2840- $ google_business_args ['cta ' ] = $ status ['googlebusiness ' ]['cta ' ];
2841- break ;
2842- }
2843-
2844- return $ google_business_args ;
2845-
2846- }
2847-
28482677 /**
28492678 * Returns default tag parameters for the given tag e.g. {title:transformation(args)} or {title}.
28502679 *
0 commit comments