flush_rules(); } } //add rewrite rules function anylink_rewrite_rules( $rules ) { $alOption = get_option( 'anylink_options' ); $cat = $alOption['redirectCat']; $newrules = array(); $newrules[$cat . '/([0-9a-z]{4,})/?$'] = 'index.php?' . $cat . '=$matches[1]'; return $newrules + $rules; } /** * This function is to replace old ACTTION hook 'publish_post' * * This change can filter and covert all post types besides * post itself. * * @param string $newStatus the new status of a post * @param string $oldStatus the old status of a post, if new to publish, it's new * @param string $post the post to add action * * @since version 0.1.4 */ function post_published( $newStatus, $oldStatus, $post) { if( $newStatus == 'publish' ) { $covert = new al_covert(); $covert -> covertURLs( $post -> ID ); } } /** * This function is to filter the post whose post type is specified * * Anylink covert all external links at all time, * but only filter the specified ones, the benefit of this is you needn't * regenerate slug any time you changed the post type * * @param object $content provided by hook * @return object $content * * @since version 0.1.4 */ function filterByType( $content ) { $type = get_post_type(); $types = get_option( 'anylink_options' ); $types = $types['postType']; if( empty( $types ) ){ return $content; } if( ( is_string( $types ) && ( $types == $type ) ) || ( is_array( $types ) && array_search( $type, $types ) !== false ) ){ $filter = new al_filter(); return $filter -> applyFilter( $content ); } else { return $content; } } ?>