JFIF $ d d 7 * Z qn )ZP 0 !1 A "#a$2Qr D8 a Ri [f \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H ~ , l s / 9 ć: [=/#f ; ) x { ٛE Q )~ = 𘙲r*2~ a _V = ' ku m F D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq 1dđ #̩ ͑ 0 ; H ] u 搂 @:~ ו K L N s h } O I R* 8 :2 ! lD JV o ( 3 = M ( z Ȱ+i *N A r6K n S l ) ! J J Ӂ* % ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c P A\IL Nj! J ۱+ O\ ͔ ] ޒ S J ȧ c%A N ol ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0 'G=i 2N +0 e 2 ]] 9 VT P O 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P < 0 x < !1AQ "Raq 02Br #S CTb ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV YT D I 6 2 '8Y2 7'\T P.6 d &˦ @V q i |8 -O Ε ] ʔ U= T L 8= ;6c | !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U#6w + +s &r+n ڐ { @ 29gL u " T Ù M=6 (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 ! OS r D 5 7 % | ?x> L | / nD 6?/8 w # [ ) L 7 +6〼T A T g ! %5 Mm Z /c -{1_Je "| ^$ 'O & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@ u6 BԒ i YN * f 0 _ GhKW u lT <nj- 0{ M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q $ H8o Q˼EV ~ k 0 h' L Pp M -M" m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @~p # !1QAa q ? AL0L x LU 4 d ; x " 16ad0 7.\ߋ 0 = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X &Q З non]я u ג./ ; gZ$ M QР 2M ]h ni 0 P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _ 1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3 6 #Ik+ v { v i ( ވ ? a e) X xy/*@Q Ǽ Ծ ) $ IWO l c G; !i k{ gOŀ L ('x T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ) X 5 c QɎMy W ? Q *!R > 6=7)Xj 5`J ] e 8%t ! + ' ! 1Q 5 !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $ v , ,m 㵜5u bV =sY+ @d { N ! dn O < .- B; _w J t 6;Q Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш e黅X ۢ F :)[ F G X ƹ / w _c MeD ,ʡc c . W D tA $ j@ : ) - #u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P 6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L ! ~ y5 g9T̅J kbM' +s :S +B) v @ M j e C f j E 0 Y\Qn z G 1 д~ W o{T 9?` Rm yhsy3 !HAD ] m c1 ~ 2 L S u7x T ;j$ `} 4-> L# vzŏ I L S ֭ T { r jGK C ; b pU= - ` Bs K. S F w4 M q] Z dH S 0 ) tLg
<?php
/**
* Subscribe forms class
*/
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
class SIB_Forms_List extends WP_List_Table {
/**
* Column headers for the table
* @var array
*/
public $_column_headers;
/**
* Items for the table
* @var array
*/
public $items;
/** Class constructor */
public function __construct() {
parent::__construct(
array('singular' => __( 'Form', 'mailin' ), //singular name of the listed records
'plural' => __( 'Forms', 'mailin' ), //plural name of the listed records
'ajax' => false) //does this table support ajax?
);
add_action( 'admin_head', array( &$this, 'admin_header' ) );
}
const PAGES = [
'sib_page_form',
'sib_page_home',
'sib_page_statistics'
];
/**
* Retrieve contacts data from the database
*
* @param int $per_page
* @param int $page_number
*
* @return mixed
*/
public static function getForms( $per_page = 5, $page_number = 1 ) {
$result = SIB_Forms::getForms();
$start = ( $page_number - 1 ) * $per_page;
usort( $result, array(__CLASS__, 'usort_reorder' ) );
$result = array_slice($result, $start, $per_page);
return $result;
}
/**
* Returns the count of records in the database.
*
* @return null|string
*/
public static function record_count() {
$result = SIB_Forms::getForms();
return count($result);
}
/** Text displayed when no customer data is available */
public function no_items() {
_e( 'No forms avaliable.', 'mailin' );
}
/**
* Render a column when no column specific method exist.
*
* @param array $item
* @param string $column_name
*
* @return mixed
*/
public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'id':
return '[sibwp_form id='.$item['id'].']';
case 'title':
case 'attributes':
case 'listName':
case 'date':
return $item[ $column_name ];
//default:
//return print_r( $item, true ); //Show the whole array for troubleshooting purposes
}
}
/**
* Render the bulk edit checkbox
*
* @param array $item
*
* @return string
*/
function column_cb( $item ) {
return sprintf(
'<input type="checkbox" name="bulk-delete[]" value="%s" />', $item['id']
);
}
/**
* Method for form title column
*
* @param array $item an array of DB data
*
* @return string
*/
function column_title( $item ) {
$delete_nonce = wp_create_nonce( 'sib_delete_form' );
$title = '<strong>' . $item['title'] . '</strong>';
$page = isset($_REQUEST['page']) && in_array(strtolower($_REQUEST['page']), self::PAGES) ? $_REQUEST['page'] : '';
$actions = array(
'edit' => sprintf( '<a href="?page=%s&action=%s&id=%s">Edit</a>', $page, 'edit', absint( $item['id'] ) ),
'duplicate' => sprintf( '<a href="?page=%s&action=%s&id=%s">Duplicate</a>', $page, 'duplicate', absint( $item['id'] ) ),
'delete' => sprintf( '<a class="sib-form-delete" href="?page=%s&action=%s&id=%s&_wpnonce=%s">Delete</a>', $page, 'delete', absint( $item['id'] ), $delete_nonce )
);
return $title . $this->row_actions( $actions );
}
function column_trans( $item ) {
$languages = apply_filters('wpml_active_languages', NULL, array());
$results = '';
if(!empty( $languages ))
{
foreach($languages as $language)
{
$exist = SIB_Forms_Lang::get_form_ID($item['id'], $language['language_code']);
$page = isset($_REQUEST['page']) && in_array(strtolower($_REQUEST['page']), self::PAGES) ? $_REQUEST['page'] : '';
if($exist == null)
{
$img_src = plugins_url('img/add_translation.png', dirname(__FILE__));
$href = sprintf( '<a href="?page=%s&action=%s&pid=%s&lang=%s" style="width: 20px; text-align: center;padding: 2px 1px;">', $page, 'edit', absint( $item['id'] ), sanitize_text_field( $language['language_code'] ) );
$results .= $href .'<img src="'.$img_src.'" style="margin:2px;"></a>';
}
else{
$img_src = plugins_url('img/edit_translation.png', dirname(__FILE__));
$href = sprintf( '<a href="?page=%s&action=%s&id=%s&pid=%s&lang=%s" style="width: 20px; text-align: center;padding: 2px 1px;">', $page, 'edit', absint( $exist ) , absint( $item['id']), sanitize_text_field( $language['language_code'] ) );
$results .= $href .'<img src="'.$img_src.'" style="margin:2px;"></a>';
}
}
}
return $results;
}
/**
* Associative array of columns
*
* @return array
*/
function get_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Form Name', 'mailin' ),
'id' => __( 'Shortcode', 'mailin' ),
'attributes' => __( 'Visible attributes', 'mailin' ),
'listName' => __( 'Linked List', 'mailin' ),
'date' => __( 'Last Update', 'mailin' )
);
if(function_exists('icl_plugin_action_links'))
{
$languages = apply_filters('wpml_active_languages', NULL, array());
$results = '';
if(!empty( $languages ))
{
foreach($languages as $language)
{
$results .= '<img src="'.$language['country_flag_url'].'" style="margin:2px;">';
}
}
$columns['trans'] = $results;
}
return $columns;
}
/**
* Columns to make sortable.
*
* @return array
*/
public function get_sortable_columns() {
$sortable_columns = array(
'date' => array( 'date', true ),
'title' => array( 'title', false ),
);
return $sortable_columns;
}
/**
* Returns an associative array containing the bulk action
*
* @return array
*/
public function get_bulk_actions() {
$actions = array(
'bulk-delete' => 'Delete'
);
$nonce = wp_create_nonce('mailin_bulk_action_nonce');
echo '<input type="hidden" name="mailin_bulk_action_nonce" value="' . esc_attr($nonce) . '">';
return $actions;
}
/**
* Handles data query and filter, sorting, and pagination.
*/
public function prepare_items() {
$this->_column_headers = $this->get_column_info();
/** Process bulk action */
$this->process_bulk_action();
$per_page = $this->get_items_per_page( 'forms_per_page', 50 );
$current_page = $this->get_pagenum();
$total_items = self::record_count();
$this->set_pagination_args( array(
'total_items' => $total_items, //WE have to calculate the total number of items
'per_page' => $per_page //WE have to determine how many items to show on a page
) );
$this->items = self::getForms( $per_page, $current_page );
}
public function process_bulk_action() {
//Detect when a bulk action is being triggered...
if ( 'delete' === $this->current_action() ) {
// In our file that handles the request, verify the nonce.
$nonce = sanitize_text_field( $_REQUEST['_wpnonce'] );
if ( ! wp_verify_nonce( $nonce, 'sib_delete_form' ) ) {
die( 'Go get a life script kiddies' );
}
else {
SIB_Forms::deleteForm( absint( sanitize_text_field($_GET['id']) ) );
SIB_Forms_Lang::remove_trans( absint( sanitize_text_field($_GET['id']) ) );
wp_redirect(add_query_arg('page', SIB_Page_Form::PAGE_ID, admin_url('admin.php'))); exit;
}
}
// If the delete bulk action is triggered
if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'bulk-delete' )
|| ( isset( $_POST['action2'] ) && $_POST['action2'] == 'bulk-delete' )
) {
$bulk_action_nonce = isset($_REQUEST['mailin_bulk_action_nonce'] ) ? sanitize_text_field( $_REQUEST['mailin_bulk_action_nonce'] ) : "";
if ( ! wp_verify_nonce( $bulk_action_nonce, 'mailin_bulk_action_nonce' ) ) {
die( 'Go get a life script kiddies' );
}
$delete_ids = array_map('intval', $_POST['bulk-delete']);
// loop over the array of record IDs and delete them
foreach ( $delete_ids as $id ) {
if( $id > 0 ) {
SIB_Forms::deleteForm( $id );
SIB_Forms_Lang::remove_trans( $id );
}
}
wp_redirect(esc_url(add_query_arg(NULL,NULL))); exit;
}
}
public function pagination($which){
echo '<a href="'.add_query_arg(array('page' => 'sib_page_form','action'=>'edit'/*,'id'=>'new'*/), admin_url('admin.php')).'" class="btn btn-success" style="float:right; margin: 2px 1px 8px 15px;" >'.__("Add New Form", "mailin").'</a>';
parent::pagination($which);
}
static function usort_reorder( $a, $b ) {
// If no sort, default to title
$orderby = ( ! empty( $_GET['orderby'] ) ) ? sanitize_text_field($_GET['orderby']) : 'title'; // by title
// If no order, default to asc
$order = ( ! empty($_GET['order'] ) ) ? sanitize_text_field($_GET['order']) : 'ask';
// Determine sort order
$result = strcmp( $a[$orderby], $b[$orderby] );
// Send final sort direction to usort
return ( $order === 'ask' ) ? $result : -$result;
}
function admin_header() {
$page = ( isset($_GET['page'] ) ) ? sanitize_text_field( $_GET['page'] ) : false;
if( 'sib_page_form' != $page )
return;
echo '<style type="text/css">';
echo '.wp-list-table .column-date { width: 150px; }';
echo '</style>';
}
}