*/ // URL or DIR PATHS define( 'ARP_PLUGIN_PATH' , plugin_dir_url( __FILE__ ) ); // PLUGIN PATH define( 'ARP_PLUGIN_DIR' , dirname( __FILE__ ) . '/' ); // PLUGIN DIRECTORY //FOLDER PATHS define( 'ARP_CLASSES_FOLDER' , ARP_PLUGIN_DIR . 'classes/'); // CLASSES FOLDER define( 'ARP_ADMIN_FOLDER' , ARP_PLUGIN_DIR . 'admin/'); // ADMIN FOLDER // Admin Settings include_once(ARP_ADMIN_FOLDER . 'class.settings-api.php'); include_once(ARP_ADMIN_FOLDER . 'amity-settings-api.php'); // Call WordPress jQuery function amity_related_posts_jquery() { wp_enqueue_script('jquery' ); } add_action('init', 'amity_related_posts_jquery' ); // Call all assets files function amity_related_posts_style(){ if (!is_admin()) { wp_register_style('amity_related_posts_css', plugins_url('/assets/css/amity-related-posts.css', __FILE__ ), '', '1.0', false); wp_enqueue_style('amity_related_posts_css'); } } add_action('init', 'amity_related_posts_style', 20); //Get the value of a settings field function arp_get_option( $option, $section, $default = '' ) { $options = get_option( $section ); if ( isset( $options[$option] ) ) { return $options[$option]; } return $default; } // Display content add_filter('the_content', 'amity_related_posts_content'); function amity_related_posts_content($content) { //if it's not a single post, than ignore if(!is_singular('post')) { return $content; } //Get Post Category from Singular Post. $categories = get_the_terms(get_the_ID(), 'category'); $categoriesIds = array(); foreach ($categories as $category) { $categoriesIds[] = $category->term_id; } //Query $args = array( 'category_in' => $categoriesIds, 'posts_per_page' => arp_get_option( 'arp-no-posts', 'arp_basics', 3), 'post_no_in' => array(get_the_ID()), 'orderby' => 'rand' ); $loop = new WP_Query($args); if ($loop->have_posts()) { $content .= ''; //Reset Query Data wp_reset_query(); } return $content; } function arp_options_style(){ ?>