Browse Source

spot edits

windhamdavid 4 years ago
parent
commit
264efaa562
2 changed files with 40 additions and 0 deletions
  1. 26 0
      functions.php
  2. 14 0
      style.css

+ 26 - 0
functions.php

@@ -361,4 +361,30 @@ function captivating_wprm_buttons() {
 		}
 		echo '</div>';
 	}
+}
+
+
+//* ##################################################################### *//
+//* Add Amazon statement after after 2nd paragraph of single post content.
+
+add_filter( 'the_content', 'prefix_insert_post_ads' );
+function prefix_insert_post_ads( $content ) {
+    $ad_code = '<div class="aws_statement"><p>This post may contain Amazon or other affiliate links. As an Amazon associate, I earn from qualifying purchases. If you purchase anything through any affiliate link, I may earn a small commission at no extra charge to you. All opinions are my own.</p></div>';
+    if ( is_single() && ! is_admin() ) {
+        return prefix_insert_after_paragraph( $ad_code, 2, $content );
+    }
+    return $content;
+}
+function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
+    $closing_p = '</p>';
+    $paragraphs = explode( $closing_p, $content );
+    foreach ($paragraphs as $index => $paragraph) {
+        if ( trim( $paragraph ) ) {
+            $paragraphs[$index] .= $closing_p;
+        }
+        if ( $paragraph_id == $index + 1 ) {
+            $paragraphs[$index] .= $insertion;
+        }
+    }  
+    return implode( '', $paragraphs );
 }

+ 14 - 0
style.css

@@ -3061,6 +3061,20 @@ ul.dpe-flexible-posts h4 {
     text-align: center;
 }
 
+#text-196.widget_text {
+  width: 50%;
+  text-align: center;
+  margin: 0 auto;
+  font-size: 12px;
+}
+a {
+  color:#00a2ae !important;
+}
+.aws_statement {
+  font-size: 12px;
+  font-style: italic;
+  color: #777;
+}
 @media only screen and (max-width: 480px) { 
   .announcement-widget {
     display:none !important;