Example #1
0
function M_ping_joinedsub($tosub_id, $tolevel_id, $to_order, $user_id)
{
    $sub = Membership_Plugin::factory()->get_subscription($tosub_id);
    $subjoiningping_id = $sub->get_meta('joining_ping');
    if (!empty($subjoiningping_id)) {
        $ping = new M_Ping($subjoiningping_id);
        $ping->send_ping($tosub_id, $tolevel_id, $user_id);
    }
    $level = Membership_Plugin::factory()->get_level($tolevel_id);
    $joiningping_id = $level->get_meta('joining_ping');
    if (!empty($joiningping_id)) {
        $ping = new M_Ping($joiningping_id);
        $ping->send_ping($tosub_id, $tolevel_id, $user_id);
    }
}
        function handle_ping_history_panel($ping_id)
        {
            global $action, $page;
            wp_reset_vars(array('action', 'page'));
            $messages = array();
            $messages[1] = __('Ping resent.', 'membership');
            $messages[2] = __('Ping not resent.', 'membership');
            ?>
			<div class='wrap'>
				<div class="icon32" id="icon-link-manager"><br></div>
				<h2><?php 
            _e('Pings History', 'membership');
            ?>
</h2>

				<?php 
            if (isset($_GET['msg'])) {
                echo '<div id="message" class="updated fade"><p>' . $messages[(int) $_GET['msg']] . '</p></div>';
                $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
            }
            $ping = new M_Ping($ping_id);
            $history = $ping->get_history();
            $columns = array("name" => __('Ping Name', 'membership'), "url" => __('URL', 'membership'), "status" => __('Status', 'membership'), "date" => __('Date', 'membership'));
            $columns = apply_filters('membership_pingscolumns', $columns);
            ?>
				<table cellspacing="0" class="widefat fixed">
					<thead>
					<tr>
					<?php 
            foreach ($columns as $key => $col) {
                ?>
							<th style="" class="manage-column column-<?php 
                echo $key;
                ?>
" id="<?php 
                echo $key;
                ?>
" scope="col"><?php 
                echo $col;
                ?>
</th>
							<?php 
            }
            ?>
					</tr>
					</thead>

					<tfoot>
					<tr>
					<?php 
            reset($columns);
            foreach ($columns as $key => $col) {
                ?>
							<th style="" class="manage-column column-<?php 
                echo $key;
                ?>
" id="<?php 
                echo $key;
                ?>
" scope="col"><?php 
                echo $col;
                ?>
</th>
							<?php 
            }
            ?>
					</tr>
					</tfoot>

					<tbody>
						<?php 
            if (!empty($history)) {
                foreach ($history as $key => $h) {
                    ?>
								<tr valign="middle" class="alternate" id="history-<?php 
                    echo $h->id;
                    ?>
">
									<td class="column-name">
										<strong><?php 
                    echo esc_html(stripslashes($ping->ping_name()));
                    ?>
</strong>
										<?php 
                    $actions = array();
                    $actions['resendnew'] = "<span class='edit'><a href='" . wp_nonce_url("?page=" . $page . "&amp;action=history&amp;resend=new&amp;history=" . $h->id, 'membership_resend_ping_' . $h->id) . "'>" . __('Resend as new ping', 'membership') . "</a></span>";
                    $actions['resendover'] = "<span class='edit'><a href='" . wp_nonce_url("?page=" . $page . "&amp;action=history&amp;resend=over&amp;history=" . $h->id, 'membership_resend_ping_' . $h->id) . "'>" . __('Resend and overwrite', 'membership') . "</a></span>";
                    ?>
										<br><div class="row-actions"><?php 
                    echo implode(" | ", $actions);
                    ?>
</div>
									</td>
									<td class="column-name">
										<?php 
                    echo $ping->ping_url();
                    ?>
									</td>
									<td class="column-name">
										<?php 
                    // Status
                    $status = unserialize($h->ping_return);
                    if (is_wp_error($status)) {
                        // WP error
                        echo "<span style='color: red;'>" . implode("<br/>", $status->get_error_messages()) . "</span>";
                    } else {
                        if (!empty($status['response'])) {
                            if ($status['response']['code'] == '200') {
                                echo "<span style='color: green;'>" . $status['response']['code'] . " - " . $status['response']['message'] . "</span>";
                            } else {
                                echo "<span style='color: red;'>" . $status['response']['code'] . " - " . $status['response']['message'] . "</span>";
                            }
                        }
                    }
                    //echo $ping->ping_url();
                    ?>
									</td>
									<td class="column-name">
										<?php 
                    echo mysql2date("Y-m-j H:i:s", $h->ping_sent);
                    ?>
									</td>
							    </tr>
								<?php 
                }
            } else {
                $columncount = count($columns);
                ?>
							<tr valign="middle" class="alternate" >
								<td colspan="<?php 
                echo $columncount;
                ?>
" scope="row"><?php 
                _e('No History available for this ping.', 'membership');
                ?>
</td>
						    </tr>
							<?php 
            }
            ?>

					</tbody>
				</table>

			</div> <!-- wrap -->
			<?php 
        }
Example #3
0
function M_ping_leftsub($fromsub_id, $fromlevel_id, $user_id)
{
    // Leaving the level
    M_ping_leftlevel($fromlevel_id, $user_id);
    // Leaving the sub
    $sub = new M_Subscription($fromsub_id);
    $subleavingping_id = $sub->get_meta('leaving_ping');
    if (!empty($subleavingping_id)) {
        $ping = new M_Ping($subleavingping_id);
        $ping->send_ping($fromsub_id, false, $user_id);
    }
}