Example #1
0
/**
 * Covert any link to be used as a parameter
 * 
 * if a link is not in an article, you can call method anylink anywhere
 * to covert it manually.
 *
 * @param string $link external link to be covert
 * @param integer $postId if the link doesn't belongs any post it will be set to 0
 *
 * @example call anylink() like this:
 * <?
 * 		echo function_exists('anylink') ? anylink('http://dudo.org', get_the_ID()) : 'http://dudo.org';
 * ?>
 * @since version 0.1.5
 */
function anylink($link, $postId = 0)
{
    require_once ANYLNK_PATH . '/config.php';
    require_once ANYLNK_PATH . '/classes/al_covert.php';
    require_once ANYLNK_PATH . '/classes/al_filter.php';
    require_once ANYLNK_PATH . '/classes/al_slug.php';
    require_once ANYLNK_PATH . '/classes/al_option.php';
    $covert = new al_covert();
    $filter = new al_filter();
    $id = $covert->storeExtLnks((array) $link);
    //because method storeRel will delete relationships
    //so we must get all relationships to compare
    $urls = $filter->getAllLnks($postId);
    if (!empty($urls)) {
        foreach ($urls as $url) {
            $oldUrlIds[] = $url['al_id'];
        }
    }
    $urlIds = array_merge($oldUrlIds, $id);
    $covert->storeRel($postId, $urlIds);
    $objSlug = $filter->getSlugById($id);
    return $filter->getInternalLinkBySlug($objSlug['al_slug']);
}
Example #2
0
        ?>
<script type="text/javascript">setDivStyle( "anylink_proceeding", <?php 
        echo round($k / $j, 4);
        ?>
 ); </script> 
<?php 
        flush();
    }
}
if (isset($_POST['action']) && $_POST['action'] == 'anylink_regnerate') {
    $alOption = get_option('anylink_options');
    if ($alOption['slugNum'] != $alOption['oldSlugNum'] || $alOption['slugChar'] != $alOption['oldSlugChar']) {
        flush();
        set_time_limit(0);
        require_once ANYLNK_PATH . "/classes/al_covert.php";
        $objAllSlug = new al_covert();
        $arrSlugID = $objAllSlug->getAllSlugID();
        $all = count($arrSlugID);
        if ($all == 0) {
            $all = 1;
        }
        $p = 0;
        $alOption['oldSlugNum'] = $alOption['slugNum'];
        $alOption['oldSlugChar'] = $alOption['slugChar'];
        update_option('anylink_options', $alOption);
        foreach ($arrSlugID as $slugID) {
            $objAllSlug->regenerateSlugByID($slugID);
            $p = $p + 1;
            ?>
	<script type="text/javascript">setDivStyle( "anylink_slug_proceeding", <?php 
            echo round($p / $all, 4);
Example #3
0
/**
 * Call actions when a new comment added
 * @param int $comment_id is the id of the comment
 * @param object $comment is the comment object
 * @since 0.1.9
 */
function new_comment($comment_id, $comment)
{
    $covert = new al_covert();
    $covert->covertURLs($comment_id, true);
}