'); $ajaxrp_options = array( 'ajaxrp_auto_show' => 1, 'ajaxrp_before_html' => '
Loading...
', 'ajaxrp_post_format' => '{post} written by {author}', 'ajaxrp_include_sticky' => 0, ); load_plugin_textdomain($ajaxrp_text_domain); function ajaxrp_install() { global $ajaxrp_options; foreach ($ajaxrp_options as $key=>$value) { add_option($key, $value); } } register_activation_hook(__FILE__, 'ajaxrp_install'); add_action('wp_enqueue_scripts', 'ajaxrp_enqueue_assets', PHP_MAX_INT); function ajaxrp_enqueue_assets() { global $ajaxrp_plugin_dir; $css_file = get_template_directory_uri() . 'ajaxrp-style.css'; if (!file_exists($css_file)) { $css_file = "{$ajaxrp_plugin_dir}css/ajaxrp-style.css"; } wp_enqueue_script('ajaxrp-onload', $ajaxrp_plugin_dir . 'js/onload.js', 'jquery', '1.0', TRUE); wp_enqueue_style('ajaxrp-css', $css_file, array(), '1.0'); } function ajaxrp_prepare_post_data($post_content) { global $post; $data = array( 'post_id' => $post->ID, ); $placeholder = ajaxrp_get_placeholder($data); if (get_option('ajaxrp_auto_show')) { // remove the custom tag (if any) and add the place holder to the end of the post $post_content = str_replace(AJAXRP_CUSTOM_TAG, '', $post_content) . $placeholder; return $post_content; } // replace the custom tag with the placeholder return str_replace(AJAXRP_CUSTOM_TAG, $placeholder, $post_content); } add_filter('the_content', 'ajaxrp_prepare_post_data', 5); function ajaxrp_get_placeholder($data) { // if this is not a single post, don't do anything if (!is_single()) { return ''; } $data = base64_encode(serialize($data)); return sprintf(' %sAJAX Random Posts is totally free, but if you think it worths some love, please consider a donation.