'Use this paragraph to provide more insights writing with clear and concise language that is easy to understand. Edit and proofread your content.', 'short' => 'Support your idea with a clear, descriptive sentence or phrase that has a consistent writing style.' ]; foreach ($sentences as $type => $search) { if (isset($base_content['sentence'][$type])) { $content = str_replace($search, $base_content['sentence'][$type], $content); } } // Process video titles if (isset($video_content['videos'])) { foreach ($video_content['videos'] as $video) { if (isset($video['title-short'])) { $replacement = 'Short title'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $video['title-short'], $pos, strlen($replacement)); } } } } // Process list items if (isset($list_content['list'])) { foreach ($list_content['list'] as $item) { if (isset($item['list-item-short'])) { if (!$is_html) { $replacement = '"text":"Add a list item"'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, '"text":"' . $item['list-item-short'] . '"', $pos, strlen($replacement)); } } $replacement = 'Add a list item'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $item['list-item-short'], $pos, strlen($replacement)); } } } } return $content; } /** * Process cards content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $columns_content The columns content. * @param boolean $is_html Whether content is HTML. * @return string */ private static function process_cards_content($content, $base_content, $columns_content, $context_ai, $context, $is_html) { // Headline medium if (isset($base_content['heading']['medium'])) { $content = str_replace( 'Craft a captivating title for this section to attract your audience.', $base_content['heading']['medium'], $content ); $content = str_replace( 'A short and sweet title for this section.', $base_content['heading']['medium'], $content ); } // Paragraph medium if (isset($base_content['sentence']['medium'])) { $content = str_replace( 'Use a clear and attention-grabbing short paragraph to engage your audience and draw them into reading the rest of your content.', $base_content['sentence']['medium'], $content ); } // Overline if (isset($base_content['overline']['short'])) { $replacements = ['ADD AN OVERLINE', 'Add an overline', 'Overline']; foreach ($replacements as $replacement) { $content = str_replace($replacement, $base_content['overline']['short'], $content); } } // Button if (isset($base_content['button']['short'])) { $content = str_replace('Call To Action', $base_content['button']['short'], $content); $content = str_replace('Call to Action', $base_content['button']['short'], $content); } // Secondary Button if (isset($base_content['secondary-button']['short'])) { $content = str_replace('Secondary Button', $base_content['secondary-button']['short'], $content); } // Process cards/columns if (isset($columns_content['columns'])) { foreach ($columns_content['columns'] as $column) { // Process various card content types $replacements = [ ['title-short', 'Add a Title'], ['title-medium', 'Add a Short Title Here'], ['sentence-short', ['Use this space to add a short description. It gives enough info to earn a click.', 'Add a brief description to your card.']], ['sentence-medium', 'Use this space to add a medium length description. Be brief and give enough information to earn a click.'], ['overline-short', 'Overline'], ['button-short', ['Call To Action', 'Call to Action']] ]; foreach ($replacements as [$key, $search]) { if (isset($column[$key])) { if (is_array($search)) { foreach ($search as $s) { $pos = strpos($content, $s); if (false !== $pos) { $content = substr_replace($content, $column[$key], $pos, strlen($s)); } } } else { $pos = strpos($content, $search); if (false !== $pos) { $content = substr_replace($content, $column[$key], $pos, strlen($search)); } } } } } } $counter_content = self::find_content_by_id($context_ai, $context . '-counter-stats'); // Metrics if ( isset($counter_content['metrics']) ) { foreach ($counter_content['metrics'] as $index => $metric) { // Title. if ( isset($counter_content['metrics'][$index]['title-short']) ) { if ( ! $is_html ) { $replacement = '"title":"Stat title"'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, '"title":"'. $counter_content['metrics'][$index]['title-short'] .'"', $pos, strlen($replacement)); } } $replacement = 'Stat title'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $counter_content['metrics'][$index]['title-short'], $pos, strlen($replacement)); } } // Price. if ( isset($counter_content['metrics'][$index]['value-short']) ) { if ( 0 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "50%", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( '"end":50', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="50', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } else if ( 1 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "98%", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( "98", absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( '"end":98', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="98', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } else if ( 2 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "100,110", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( '"end":100110', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="100110', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } else if ( 3 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "8/mo", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( '"end":8', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="8', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } else if ( 4 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "20yr", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( '"end":20', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="20', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } else if ( 5 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "18,110", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( '"end":18110', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="18110', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } } } } return $content; } /** * Process testimonials content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $context_ai The context AI content. * @param string $context The context. * @return string */ private static function process_testimonials_content($content, $base_content, $context_ai, $context, $is_html) { $testimonial_content = self::find_content_by_id($context_ai, $context . '-testimonials'); // Overline if (isset($testimonial_content['overline']['short'])) { $replacements = ['ADD AN OVERLINE', 'Add an overline', 'Overline']; foreach ($replacements as $replacement) { $content = str_replace($replacement, $testimonial_content['overline']['short'], $content); } } elseif (isset($base_content['overline']['short'])) { $replacements = ['ADD AN OVERLINE', 'Add an overline', 'Overline']; foreach ($replacements as $replacement) { $content = str_replace($replacement, $base_content['overline']['short'], $content); } } // Button if (isset($testimonial_content['button']['short'])) { $replacements = ['Call To Action', 'Call to Action']; foreach ($replacements as $replacement) { $content = str_replace($replacement, $testimonial_content['button']['short'], $content); } } elseif (isset($base_content['button']['short'])) { $replacements = ['Call To Action', 'Call to Action']; foreach ($replacements as $replacement) { $content = str_replace($replacement, $base_content['button']['short'], $content); } } // Headline short if (isset($testimonial_content['heading']['short'])) { $content = str_replace( 'Type a short headline', $testimonial_content['heading']['short'], $content ); } elseif (isset($base_content['heading']['short'])) { $content = str_replace( 'Type a short headline', $base_content['heading']['short'], $content ); } // Headline medium if (isset($testimonial_content['heading']['medium'])) { $content = str_replace( 'Add a compelling title for your section to engage your audience.', $testimonial_content['heading']['medium'], $content ); } elseif (isset($base_content['heading']['medium'])) { $content = str_replace( 'Add a compelling title for your section to engage your audience.', $base_content['heading']['medium'], $content ); } // Paragraph long $long_text = 'Use this paragraph section to get your website visitors to know you. Consider writing about you or your organization, the products or services you offer, or why you exist. Keep a consistent communication style.'; if (isset($testimonial_content['sentence']['long'])) { $content = str_replace($long_text, $testimonial_content['sentence']['long'], $content); } elseif (isset($base_content['sentence']['long'])) { $content = str_replace($long_text, $base_content['sentence']['long'], $content); } // Process testimonials if (isset($testimonial_content['testimonials'])) { foreach ($testimonial_content['testimonials'] as $testimonial) { if (isset($testimonial['customer'])) { $replacement = 'Customer Name'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $testimonial['customer'], $pos, strlen($replacement)); } } if (isset($testimonial['customer-name'])) { $replacement = 'Customer Name'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $testimonial['customer-name'], $pos, strlen($replacement)); } } if (isset($testimonial['customer-occupation'])) { $replacement = 'Customer Title'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $testimonial['customer-occupation'], $pos, strlen($replacement)); } } if (isset($testimonial['testimonial'])) { $replacements = [ 'Testimonials are a social proof, a powerful way to inspire trust.', 'Testimonials, as authentic endorsements from satisfied customers, serve as potent social proof, significantly inspiring trust in potential consumers.' ]; foreach ($replacements as $replacement) { $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $testimonial['testimonial'], $pos, strlen($replacement)); } } } } } return $content; } /** * Process pricing table content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $context_ai The context AI content. * @param string $context The context. * @param boolean $is_html Whether content is HTML. * @return string */ private static function process_pricing_table_content($content, $base_content, $context_ai, $context, $is_html) { $pricing_table_content = self::find_content_by_id($context_ai, 'pricing-' . $context); // Headline short if (isset($pricing_table_content['heading']['short'])) { $content = str_replace('Write a short headline', $pricing_table_content['heading']['short'], $content); $content = str_replace( 'Add a compelling title for your section to engage your audience.', $pricing_table_content['heading']['short'], $content ); } // Paragraph short/medium/long $paragraphs = [ 'short' => 'Add a gripping description for this featured plan', 'medium' => 'A pricing table assists users in selecting a suitable plan by simply and clearly differentiating product/service features and prices. Use this as supporting text for your plans.', 'long' => 'A pricing table assists users in selecting a suitable plan by simply and clearly differentiating product/service features and prices. Use this as supporting text for your plans.' ]; foreach ($paragraphs as $type => $search) { if (isset($pricing_table_content['sentence'][$type])) { $content = str_replace($search, $pricing_table_content['sentence'][$type], $content); } } // Overline if (isset($pricing_table_content['overline']['short'])) { $content = str_replace('add an overline text', $pricing_table_content['overline']['short'], $content); $content = str_replace('Add an overline text', $pricing_table_content['overline']['short'], $content); } // Process plans if (isset($pricing_table_content['plans'])) { foreach ($pricing_table_content['plans'] as $index => $plan) { // Title if (isset($plan['title-short'])) { $replacement = 'Tab Title'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $plan['title-short'], $pos, strlen($replacement)); } } if (isset($plan['title-medium'])) { $replacement = 'Name your plan'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $plan['title-medium'], $pos, strlen($replacement)); } $replacement = 'Add a descriptive title for your plan.'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $plan['title-medium'], $pos, strlen($replacement)); } } // Price if (isset($plan['price'])) { $price = preg_replace('/\/(?:month|year)/', '', $plan['price']); $price_map = ['$60', '$80', '$120', '$200']; if (isset($price_map[$index]) && strlen($price) < 8) { $replacement = $price_map[$index]; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $price, $pos, strlen($replacement)); } } } // Features for ($i = 1; $i <= 3; $i++) { if (isset($plan['feature-' . $i])) { $feature_map = [ 1 => 'Focus on the differences', 2 => 'Use a consistent language', 3 => 'Transmit benefits clearly' ]; if (!$is_html) { $replacement = $feature_map[$i]; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $plan['feature-' . $i], $pos, strlen($replacement)); } } $replacement = $feature_map[$i]; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $plan['feature-' . $i], $pos, strlen($replacement)); } } } } } return $content; } /** * Process post loop content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $context_ai The context AI content. * @param string $context The context. * @return string */ private static function process_post_loop_content($content, $base_content, $context_ai, $context) { $post_loop_content = self::find_content_by_id($context_ai, $context . '-post-loop'); // Headline short if (isset($post_loop_content['heading']['short'])) { $content = str_replace('Selected posts title', $post_loop_content['heading']['short'], $content); } elseif (isset($base_content['heading']['short'])) { $content = str_replace('Selected posts title', $base_content['heading']['short'], $content); } // Headline medium if (isset($post_loop_content['heading']['medium'])) { $content = str_replace( 'Craft a captivating title for this section to attract your audience.', $post_loop_content['heading']['medium'], $content ); } elseif (isset($base_content['heading']['medium'])) { $content = str_replace( 'Craft a captivating title for this section to attract your audience.', $base_content['heading']['medium'], $content ); } // Process other content types with fallbacks $replacements = [ ['sentence', 'short', 'Use a clear and attention-grabbing short paragraph to engage your audience and draw them into reading the rest of your content.'], ['overline', 'short', ['ADD AN OVERLINE', 'Add an overline', 'Overline']], ['button', 'short', ['Call To Action', 'Call to Action']] ]; foreach ($replacements as [$type, $length, $search]) { $content_value = isset($post_loop_content[$type][$length]) ? $post_loop_content[$type][$length] : (isset($base_content[$type][$length]) ? $base_content[$type][$length] : null); if ($content_value) { if (is_array($search)) { foreach ($search as $s) { $content = str_replace($s, $content_value, $content); } } else { $content = str_replace($search, $content_value, $content); } } } return $content; } /** * Process team content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $context_ai The context AI content. * @param string $context The context. * @return string */ private static function process_team_content($content, $base_content, $context_ai, $context) { $people_content = self::find_content_by_id($context_ai, $context . '-people'); // Process headings and sentences with fallbacks $replacements = [ ['heading', 'medium', [ 'A short and sweet title for this section.', 'Craft a captivating title for this section to attract your audience.' ]], ['sentence', 'short', 'Use this space to write about your company, employee profiles and organizational culture; share your story and connect with customers.'], ['overline', 'short', ['ADD AN OVERLINE', 'Add an overline', 'Overline']], ['button', 'short', ['Call To Action', 'Call to Action']] ]; foreach ($replacements as [$type, $length, $search]) { $content_value = isset($people_content[$type][$length]) ? $people_content[$type][$length] : (isset($base_content[$type][$length]) ? $base_content[$type][$length] : null); if ($content_value) { if (is_array($search)) { foreach ($search as $s) { $content = str_replace($s, $content_value, $content); } } else { $content = str_replace($search, $content_value, $content); } } } // Process people if (isset($people_content['people'])) { foreach ($people_content['people'] as $person) { if (isset($person['name'])) { $replacement = 'Name Lastname'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $person['name'], $pos, strlen($replacement)); } } if (isset($person['position'])) { $replacement = 'Position or title'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $person['position'], $pos, strlen($replacement)); } } if (isset($person['sentence-short'])) { $replacement = "Brief profile bio for this person will live here. Add an overview of this person's role or any key information."; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $person['sentence-short'], $pos, strlen($replacement)); } } } } return $content; } /** * Process logo farm content * * @param string $content The content to process. * @param array $base_content The base content. * @return string */ private static function process_logo_farm_content($content, $base_content) { // Headline medium if (isset($base_content['heading']['medium'])) { $content = str_replace( 'Tell your audience about your achievements, partners or customers.', $base_content['heading']['medium'], $content ); } // Overline if (isset($base_content['overline']['short'])) { $replacements = ['ADD AN OVERLINE', 'Add an overline', 'Overline']; foreach ($replacements as $replacement) { $content = str_replace($replacement, $base_content['overline']['short'], $content); } } // Button if (isset($base_content['button']['short'])) { $content = str_replace('Call To Action', $base_content['button']['short'], $content); $content = str_replace('Call to Action', $base_content['button']['short'], $content); } return $content; } /** * Process location content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $columns_content The columns content. * @return string */ private static function process_location_content($content, $base_content, $columns_content) { // Headline short if (isset($base_content['heading']['short'])) { $replacements = [ 'Find us', 'Write a short headline' ]; foreach ($replacements as $replacement) { $content = str_replace($replacement, $base_content['heading']['short'], $content); } } // Headline medium if (isset($base_content['heading']['medium'])) { $content = str_replace( 'Compose a captivating title for this section.', $base_content['heading']['medium'], $content ); } // Process sentences $sentences = [ 'short' => [ 'Support your idea with a clear, descriptive sentence or phrase that has a consistent writing style.', 'Use a brief and inviting sentence to encourage visitors to get in touch.' ], 'medium' => 'Use this paragraph to provide more insights writing with clear and concise language that is easy to understand. Edit and proofread your content.' ]; foreach ($sentences as $type => $searches) { if (isset($base_content['sentence'][$type])) { if (is_array($searches)) { foreach ($searches as $search) { $content = str_replace($search, $base_content['sentence'][$type], $content); } } else { $content = str_replace($searches, $base_content['sentence'][$type], $content); } } } // Process columns if (isset($columns_content['columns'])) { foreach ($columns_content['columns'] as $column) { if (isset($column['title-medium'])) { $replacement = 'Add a descriptive title for the column.'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $column['title-medium'], $pos, strlen($replacement)); } } if (isset($column['sentence-short'])) { $replacement = 'Add context to your column. Help visitors understand the value they can get from your products and services.'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $column['sentence-short'], $pos, strlen($replacement)); } } } } return $content; } /** * Process gallery content * * @param string $content The content to process. * @param array $base_content The base content. * @return string */ private static function process_gallery_content($content, $base_content) { // Headline short if (isset($base_content['heading']['short'])) { $content = str_replace('Add a succinct headline', $base_content['heading']['short'], $content); } if (isset($base_content['heading']['medium'])) { $content = str_replace('Briefly and concisely explain what you do for your audience.', $base_content['heading']['medium'], $content); } // Sentence long if (isset($base_content['sentence']['long'])) { $content = str_replace( 'Use this paragraph section to get your website visitors to know you. Write about you or your organization, the products or services you offer, or why you exist. Keep a consistent communication style. Consider using this if you need to provide more context on why you do what you do. Be engaging. Focus on delivering value to your visitors.', $base_content['sentence']['long'], $content ); } // Sentence medium if (isset($base_content['sentence']['medium'])) { $content = str_replace( 'Consider using this if you need to provide more context on why you do what you do. Be engaging. Focus on delivering value to your visitors.', $base_content['sentence']['medium'], $content ); } // Sentence short if (isset($base_content['sentence']['short'])) { $content = str_replace( 'Write with clear, concise language to inform and engage your audience. Consider what matters to them and provide valuable insights.', $base_content['sentence']['short'], $content ); } return $content; } /** * Process featured products content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $context_ai The context AI content. * @param string $context The context. * @return string */ private static function process_featured_products_content($content, $base_content, $context_ai, $context, $is_html) { $featured_content = self::find_content_by_id($context_ai, $context . '-single'); // Headline medium if (isset($featured_content['heading']['medium'])) { $content = str_replace( 'An engaging product or feature headline here', $featured_content['heading']['medium'], $content ); } elseif (isset($base_content['heading']['medium'])) { $content = str_replace( 'An engaging product or feature headline here', $base_content['heading']['medium'], $content ); } // Sentence medium if (isset($featured_content['sentence']['medium'])) { $content = str_replace( 'Write a short descriptive paragraph about your product. Focus on your ideal buyer. Entice with benefits of using your product.', $featured_content['sentence']['medium'], $content ); } elseif (isset($base_content['sentence']['medium'])) { $content = str_replace( 'Write a short descriptive paragraph about your product. Focus on your ideal buyer. Entice with benefits of using your product.', $base_content['sentence']['medium'], $content ); } // Price if (isset($featured_content['price'])) { $content = str_replace('$19.99', $featured_content['price'], $content); } // Button if (isset($featured_content['button']['short'])) { $content = str_replace('Call To Action', $featured_content['button']['short'], $content); $content = str_replace('Call to Action', $featured_content['button']['short'], $content); } elseif (isset($base_content['button']['short'])) { $content = str_replace('Call To Action', $base_content['button']['short'], $content); $content = str_replace('Call to Action', $base_content['button']['short'], $content); } // Process benefits if (isset($featured_content['product-features-and-benefits'])) { foreach ($featured_content['product-features-and-benefits'] as $index => $benefit) { if (isset($benefit['list-item-short'])) { $replacement = ($index % 2 !== 0) ? 'Another short feature description' : 'Short feature description'; if (!$is_html) { $temp_replacement = '"text":"' . $replacement . '"'; $pos = strpos($content, $temp_replacement); if (false !== $pos) { $content = substr_replace($content, '"text":"' . $benefit['list-item-short'] . '"', $pos, strlen($temp_replacement)); } } $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $benefit['list-item-short'], $pos, strlen($replacement)); } } } } return $content; } /** * Process product loop content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $columns_content The columns content. * @return string */ private static function process_product_loop_content($content, $base_content, $columns_content, $context_ai, $context) { $hero_content = self::find_content_by_id($context_ai, $context . '-hero'); // Process various content types $replacements = [ ['heading', 'short', 'Type a short headline'], ['heading', 'medium', 'Briefly and concisely explain what you do for your audience.'], ['sentence', 'long', 'Use this paragraph section to get your website visitors to know you. Write about you or your organization, the products or services you offer, or why you exist. Keep a consistent communication style. Consider using this if you need to provide more context on why you do what you do. Be engaging. Focus on delivering value to your visitors.'], ['sentence', 'medium', 'Consider using this if you need to provide more context on why you do what you do. Be engaging. Focus on delivering value to your visitors.'], ['sentence', 'short', [ 'Consider using this if you need to provide more context on why you do what you do.', 'Consider using this if you need to provide more context on why you do what you do. Be engaging.' ]], ['overline', 'short', ['2018 - Current', 'Add an overline text', 'Overline']], ['button', 'short', ['Call To Action', 'Call to Action']] ]; foreach ($replacements as [$type, $length, $search]) { if (isset($hero_content[$type][$length])) { if (is_array($search)) { foreach ($search as $s) { $content = str_replace($s, $hero_content[$type][$length], $content); } } else { $content = str_replace($search, $hero_content[$type][$length], $content); } } if (isset($base_content[$type][$length])) { if (is_array($search)) { foreach ($search as $s) { $content = str_replace($s, $base_content[$type][$length], $content); } } else { $content = str_replace($search, $base_content[$type][$length], $content); } } } // Process columns if (isset($columns_content['columns'])) { foreach ($columns_content['columns'] as $column) { $column_replacements = [ ['title-short', 'Add a short title'], ['sentence-short', 'Use this space to add a short description.'], ['sentence-medium', 'Use this space to add a medium length description. Be brief and give enough information to earn their attention.'] ]; foreach ($column_replacements as [$key, $search]) { if (isset($column[$key])) { $pos = strpos($content, $search); if (false !== $pos) { $content = substr_replace($content, $column[$key], $pos, strlen($search)); } } } } } return $content; } /** * Process form content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $ai_content The AI content. * @return string */ private static function process_form_content($content, $base_content, $ai_content) { $text_content = ''; $about_content = isset($ai_content['about']['content']) ? $ai_content['about']['content'] : null; if ($about_content) { $text_content = self::find_content_by_id($about_content, 'about'); } // Headline short if (isset($base_content['heading']['short'])) { $content = str_replace('Add A Title For Your Form', $base_content['heading']['short'], $content); } // Sentence short if (isset($base_content['sentence']['short'])) { $content = str_replace( 'Briefly describe what the form is for or provide additional context if required. Use inviting language.', $base_content['sentence']['short'], $content ); } // Paragraph long from about content if (isset($text_content['sentence']['long'])) { $content = str_replace( 'Use this paragraph section to get your website visitors to know you. Write about you or your organization, the products or services you offer, or why you exist. Keep a consistent communication style. Consider using this if you need to provide more context on why you do what you do. Be engaging. Focus on delivering value to your visitors.', $text_content['sentence']['long'], $content ); } return $content; } /** * Process table of contents content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $context_ai The context AI content. * @param string $context The context. * @return string */ private static function process_table_of_contents_content($content, $base_content, $context_ai, $context) { $toc_content = self::find_content_by_id($context_ai, $context . '-table-contents'); // Headline medium if (isset($toc_content['heading']['medium'])) { $content = str_replace( 'Craft a captivating title for this section to attract your audience.', $toc_content['heading']['medium'], $content ); } elseif (isset($base_content['heading']['medium'])) { $content = str_replace( 'Craft a captivating title for this section to attract your audience.', $base_content['heading']['medium'], $content ); } // Process other content types with fallbacks $replacements = [ ['overline', 'short', ['ADD AN OVERLINE', 'Add an overline', 'Overline']], ['button', 'short', ['Call To Action', 'Call to Action']] ]; foreach ($replacements as [$type, $length, $search]) { $content_value = isset($toc_content[$type][$length]) ? $toc_content[$type][$length] : (isset($base_content[$type][$length]) ? $base_content[$type][$length] : null); if ($content_value) { if (is_array($search)) { foreach ($search as $s) { $content = str_replace($s, $content_value, $content); } } else { $content = str_replace($search, $content_value, $content); } } } // Process subtitles if (isset($toc_content['subtitles'])) { foreach ($toc_content['subtitles'] as $subtitle) { if (isset($subtitle['title-short'])) { $replacement = 'Write a title for your section or related content here'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $subtitle['title-short'], $pos, strlen($replacement)); } } } } return $content; } /** * Process counter or stats content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $context_ai The context AI content. * @param string $context The context. * @return string */ private static function process_counter_or_stats_content($content, $base_content, $context_ai, $base_testimonial_content, $context, $is_html) { $counter_content = self::find_content_by_id($context_ai, $context . '-counter-stats'); // Headline. if ( isset($counter_content['heading']['medium']) ) { $content = str_replace( 'Tell your story in numbers, and give your visitors useful insights.', $counter_content['heading']['medium'], $content ); } elseif ( isset($base_content['heading']['medium']) ) { $content = str_replace( 'Tell your story in numbers, and give your visitors useful insights.', $base_content['heading']['medium'], $content ); } // Paragraph medium if ( isset($counter_content['sentence']['medium']) ) { $content = str_replace( 'Make an impact, and share your organization\'s stats or achievements to interest your website visitors into learning more about you.', $counter_content['sentence']['medium'], $content ); } elseif ( isset($base_content['sentence']['medium']) ) { $content = str_replace( 'Make an impact, and share your organization\'s stats or achievements to interest your website visitors into learning more about you.', $base_content['sentence']['medium'], $content ); } // overline if ( isset($counter_content['overline']['short']) ) { $content = str_replace( 'ADD AN OVERLINE TEXT', $counter_content['overline']['short'], $content ); $content = str_replace( 'Add an overline text', $counter_content['overline']['short'], $content ); $content = str_replace( 'Overline', $counter_content['overline']['short'], $content ); } elseif ( isset($base_content['overline']['short']) ) { $content = str_replace( 'ADD AN OVERLINE TEXT', $base_content['overline']['short'], $content ); $content = str_replace( 'Add an overline text', $base_content['overline']['short'], $content ); $content = str_replace( 'Overline', $base_content['overline']['short'], $content ); } // Button if ( isset($counter_content['button']['short']) ) { $content = str_replace( 'Call To Action', $counter_content['button']['short'], $content ); $content = str_replace( 'Call to Action', $counter_content['button']['short'], $content ); } elseif ( isset($base_content['button']['short']) ) { $content = str_replace( 'Call To Action', $base_content['button']['short'], $content ); $content = str_replace( 'Call to Action', $base_content['button']['short'], $content ); } // Metrics if ( isset($counter_content['metrics']) ) { foreach ($counter_content['metrics'] as $index => $metric) { // Title. if ( isset($counter_content['metrics'][$index]['title-short']) ) { if ( ! $is_html ) { $replacement = '"title":"Stat title"'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, '"title":"'. $counter_content['metrics'][$index]['title-short'] .'"', $pos, strlen($replacement)); } } $replacement = 'Stat title'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $counter_content['metrics'][$index]['title-short'], $pos, strlen($replacement)); } } // Price. if ( isset($counter_content['metrics'][$index]['value-short']) ) { if ( 0 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "50%", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( '"end":50', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="50', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } else if ( 1 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "98%", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( "98", absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( '"end":98', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="98', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } else if ( 2 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "100,110", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( '"end":100110', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="100110', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } else if ( 3 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "8/mo", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( '"end":8', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="8', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } else if ( 4 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "20yr", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( '"end":20', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="20', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } else if ( 5 === $index ) { if ( strlen($counter_content['metrics'][$index]['value-short']) < 8 ) { $content = str_replace( "18,110", $counter_content['metrics'][$index]['value-short'], $content ); $content = str_replace( '"end":18110', '"end":'. absint($counter_content['metrics'][$index]['value-short']), $content ); $content = str_replace( 'data-end="18110', 'data-end="'. absint($counter_content['metrics'][$index]['value-short']), $content ); } } } } } // List if ( isset($counter_content['list']) ) { foreach ($counter_content['list'] as $index => $item) { // list item. if ( isset($item['list-item-short']) ) { if (!$is_html) { $replacement = '"text":"Add a single and succinct list item"'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, '"text":"' . $item['list-item-short'] . '"', $pos, strlen($replacement)); } } $replacement = "Add a single and succinct list item"; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $item['list-item-short'], $pos, strlen($replacement)); } } // list item long. if ( isset($item['list-item-long']) ) { if (!$is_html) { $replacement = '"text":"Add unique list items while keeping a consistent phrasing style and similar line lengths"'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, '"text":"' . $item['list-item-long'] . '"', $pos, strlen($replacement)); } } $replacement = "Add unique list items while keeping a consistent phrasing style and similar line lengths"; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $item['list-item-long'], $pos, strlen($replacement)); } } } } // Process testimonials if (isset($base_testimonial_content['testimonials'])) { foreach ($base_testimonial_content['testimonials'] as $testimonial) { if (isset($testimonial['customer'])) { $replacement = 'Customer Name'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $testimonial['customer'], $pos, strlen($replacement)); } } if (isset($testimonial['customer-name'])) { $replacement = 'Customer Name'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $testimonial['customer-name'], $pos, strlen($replacement)); } } if (isset($testimonial['customer-occupation'])) { $replacement = 'Customer Title'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $testimonial['customer-occupation'], $pos, strlen($replacement)); } } if (isset($testimonial['testimonial'])) { $replacements = [ 'Testimonials are a social proof, a powerful way to inspire trust.', 'Testimonials, as authentic endorsements from satisfied customers, serve as potent social proof, significantly inspiring trust in potential consumers.' ]; foreach ($replacements as $replacement) { $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $testimonial['testimonial'], $pos, strlen($replacement)); } } } } } return $content; } /** * Process list content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $context_ai The context AI content. * @param string $context The context. * @return string */ private static function process_list_content($content, $base_content, $context_ai, $context, $is_html) { $list_content = self::find_content_by_id($context_ai, $context . '-list'); $columns_content = self::find_content_by_id($context_ai, $context . '-columns'); // Headline Short. if ( isset($base_content['heading']['short']) ) { $content = str_replace( 'Write a short and relevant headline', $base_content['heading']['short'], $content ); } // Headline. if ( isset($base_content['heading']['medium']) ) { $content = str_replace( 'Write a clear and relevant header to keep your visitors engaged', $base_content['heading']['medium'], $content ); } // Paragraph medium if ( isset($base_content['sentence']['medium']) ) { $content = str_replace( 'Use this paragraph section to get your website visitors to know you. Consider writing about you or your organization, the products or services you offer, or why you exist. Keep a consistent communication style.', $base_content['sentence']['medium'], $content ); } // overline if ( isset($base_content['overline']['short']) ) { $content = str_replace( 'ADD AN OVERLINE TEXT', $base_content['overline']['short'], $content ); $content = str_replace( 'Add an overline text', $base_content['overline']['short'], $content ); $content = str_replace( 'Overline', $base_content['overline']['short'], $content ); } // Button if ( isset($base_content['button']['short']) ) { $content = str_replace( 'Call To Action', $base_content['button']['short'], $content ); $content = str_replace( 'Call to Action', $base_content['button']['short'], $content ); } // Columns if ( isset($columns_content['columns']) ) { foreach ($columns_content['columns'] as $index => $column) { // Title. if ( isset($column['title-medium']) ) { $replacement = "Give your list item a title"; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $column['title-medium'], $pos, strlen($replacement)); } } // Sentence Short. if ( isset($column['sentence-short']) ) { $replacement = "Use this short paragraph to write a supporting description of your list item. Remember to let your readers know why this list item is essential."; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $column['sentence-short'], $pos, strlen($replacement)); } } } } // List if ( isset($list_content['list']) ) { foreach ($list_content['list'] as $index => $item) { // list item. if ( isset($item['list-item-short']) ) { if (!$is_html) { $replacement = '"text":"Add a single and succinct list item"'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, '"text":"' . $item['list-item-short'] . '"', $pos, strlen($replacement)); } } $replacement = "Add a single and succinct list item"; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $item['list-item-short'], $pos, strlen($replacement)); } } // list item long. if ( isset($item['list-item-long']) ) { if (!$is_html) { $replacement = '"text":"Add unique list items while keeping a consistent phrasing style and similar line lengths"'; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, '"text":"' . $item['list-item-long'] . '"', $pos, strlen($replacement)); } } $replacement = "Add unique list items while keeping a consistent phrasing style and similar line lengths"; $pos = strpos($content, $replacement); if (false !== $pos) { $content = substr_replace($content, $item['list-item-long'], $pos, strlen($replacement)); } } } } return $content; } /** * Process slider content * * @param string $content The content to process. * @param array $base_content The base content. * @param array $context_ai The context AI content. * @param string $context The context. * @return string */ private static function process_slider_content($content, $base_content, $context_ai, $context, $is_html) { // Headline. if ( isset($base_content['heading']['short']) ) { $content = str_replace( 'Short Headline', $base_content['heading']['short'], $content ); } // Headline. if ( isset($base_content['heading']['medium']) ) { $content = str_replace( 'Craft a captivating title to attract your audience.', $base_content['heading']['medium'], $content ); } // Headline. if ( isset($base_content['sentence']['short']) ) { $content = str_replace( 'Use a clear and attention-grabbing short paragraph to engage your audience and draw them into reading the rest of your content.', $base_content['sentence']['short'], $content ); } // overline if ( isset($base_content['overline']['short']) ) { $content = str_replace( 'ADD AN OVERLINE', $base_content['overline']['short'], $content ); $content = str_replace( 'Add an overline', $base_content['overline']['short'], $content ); $content = str_replace( 'Overline', $base_content['overline']['short'], $content ); } // Button if ( isset($base_content['button']['short']) ) { $content = str_replace( 'Call To Action', $base_content['button']['short'], $content ); $content = str_replace( 'Call to Action', $base_content['button']['short'], $content ); } return $content; } }