Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter czdah13

    (@czdah13)

    @ancawonka thanks a lot,
    this article helped me to make something. but I need make $paging function to get arrays 20 by 20 from get_entries() and show them,
    https://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/
    for now my code is like this :
    https://beepaste.io/view/NOeJhD

    Thread Starter czdah13

    (@czdah13)

    https://developer.www.ads-software.com/reference/functions/add_user_meta/

    Thread Starter czdah13

    (@czdah13)

    I`m trying to make better list base of this:
    https://www.smashingmagazine.com/2011/11/native-admin-tables-wordpress/

    I tried to change prepare_item() for array :

    $plugin_dir_path = dirname(__FILE__);
    include($plugin_dir_path.'/class-wp-list-table.php');
    class Link_List_Table extends WP_gf_List_Table {
    	
    	   /**
    		* Constructor, we override the parent to pass our own arguments
    		* We usually focus on three parameters: singular and plural labels, as well as whether the class supports AJAX.
    		*/
    		public $gf_filter;
    		function __construct() {
    		   parent::__construct( array(
    		  'singular'=> 'wp_list_text_link', //Singular label
    		  'plural' => 'wp_list_test_links', //plural label, also this well be one of the table css class
    		  'ajax'   => false //We won't support Ajax for this table
    		  ) );
    		}
    		function get_columns() {
    			return $columns= array(
    			   'col_gf_id'=>__('????? ???????'),
    			   'col_gf_fname'=>__('???'),
    			   'col_gf_lname'=>__('??? ????????'),
    			   'col_gf_phone'=>__('????? ????'),
    			   'col_gf_socialid'=>__('?????')
    			);
    		 }
    		 /**
     * Decide which columns to activate the sorting functionality on
     * @return array $sortable, the array of columns that can be sorted by the user
     */
    public function get_sortable_columns() {
    	return $sortable = array(
    		'col_gf_id' => 'gf_entry_id',
    		'col_gf_lname'=>'gf_entry_lname',
    	);
    	function prepare_items() {
    		global $_wp_column_headers;
    		$search_criteria = array ('status'        => 'active',
    		'field_filters' => array(
    			'mode' => 'any',
    			array(
    				'key'   => '5',
    				'value' => $gf_filter
    			)
    	));
    	$entries = GFAPI::get_entries( '3', $search_criteria );
    	$entry_list = [];
    	
    	for ($i = 0; $i < count($entries); $i++ )
    	{
    		array_push ($entry_list,array(
    		$entries[$i]['id'],
    		$entries[$i]['date_created'],
    		$entries[$i]['1.3'],
    		$entries[$i]['1.6'],
    		$entries[$i][19],
    		$entries[$i][10],
    		$entries[$i][37]
    							));
    	}
    
    		$screen = get_current_screen();
    	 
    		/* -- Preparing your query -- */
    		
    		
    		   //The pagination links are automatically built according to those parameters
    	 
    		/* -- Register the Columns -- */
    		   $columns = $this->get_columns();
    		   $_wp_column_headers[$screen->id]=$columns;
    	 
    		/* -- Fetch the items -- */
    		   $this->items = $entry_list;
    	 }
    	 function display_rows() {
    		
    		   //Get the records registered in the prepare_items method
    		   $records = $this->items;
    		
    		   //Get the columns registered in the get_columns and get_sortable_columns methods
    		   list( $columns, $hidden ) = $this->get_column_info();
    		
    		   //Loop for each record
    		   if(!empty($records)){foreach($records as $rec){
    		
    			  //Open the line
    				echo '< tr id="record_'.$rec[0].'">';
    			  foreach ( $columns as $column_name => $column_display_name ) {
    		
    				 //Style attributes for each col
    				 $class = "class='$column_name column-$column_name'";
    				 $style = "";
    				 if ( in_array( $column_name, $hidden ) ) $style = ' style="display:none;"';
    				 $attributes = $class . $style;
    		
    				 //edit link
    				 $editlink  = '/wp-admin/admin.php?page=gf_entries&view=entry&id=3&lid='.(int)$rec[0];
    		
    				 //Display the cell
    				 switch ( $column_name ) {
    					case "col_gf_id":  echo '< td '.$attributes.'>'.stripslashes($rec[0]).'< /td>';   break;
    					case "col_gf_fname": echo '< td '.$attributes.'>'.stripslashes($rec[1]).'7< /td>'; break;
    					case "col_gf_lname": echo '< td '.$attributes.'>'.stripslashes($rec[2]).'< /td>'; break;
    					case "col_gf_phone": echo '< td '.$attributes.'>'.$rec[3].'< /td>'; break;
    					case "col_gf_socialid": echo '< td '.$attributes.'>'.$rec[4].'< /td>'; break;
    				 }
    			  }
    		
    			  //Close the line
    			  echo'< /tr>';
    		   }}
    		}
    
    

    and calling class by :

    $wp_list_table = new Link_List_Table();
    $wp_list_table->gf_filter="???? ????";
    $wp_list_table->prepare_items();
    $wp_list_table->display();

    but I got this error :

    
    function WP_List_Table::prepare_items() must be over-ridden in a sub-class.

    my complete plugin code:
    https://beepaste.io/view/jkYyr2
    and example of my array :
    https://beepaste.io/view/VCYu1A

    • This reply was modified 7 years, 4 months ago by czdah13.
    • This reply was modified 7 years, 4 months ago by czdah13.
    Thread Starter czdah13

    (@czdah13)

    @ancawonka
    so far I wrote this for test :

    <?php
    /* Plugin Name: Gravity forms access level 
    Plugin URI: https://sae13.ir/archives/tag/wordpress
    Description: Show Only part of Gravity form data which user hass allow to access
    Version: 0.0.0.1
    Author:Saeb Molaee
    Author URI:https://twitter.com/sae13
    License:     GPL2
     
    {Plugin Name} is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    any later version.
     
    {Plugin Name} is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.
     
    You should have received a copy of the GNU General Public License
    along with {Plugin Name}. If not, see {License URI}.
    
    */
    
    //add_action( 'admin_notices', 'main_gf_access_level' );
    /* how to define page in admin menu:
    add_menu_page(
        string $page_title,
        string $menu_title,
        string $capability,
        string $menu_slug, 
        callable $function = '',
        string $icon_url = '',
        int $position = null
    );
    
    */
    $plugin_dir_path = dirname(__FILE__);
    include($plugin_dir_path.'/class-wp-list-table.php');
    
    function main_gf_access_level(){
    $forms = GFAPI::get_forms();
    var_dump( $forms );}
    function gf_access_level_page_menu()
    {
        add_menu_page(
            '?????? ???? ??',
            '????? ???? ??',
            'read',
            'wporg',
            'gf_access_level_entity_page',
            plugin_dir_url(__FILE__) . 'images/icon_wporg.png',
            20
        );
    }
    add_action('admin_menu', 'gf_access_level_page_menu');
    
    ?>
    <?php
    function gf_access_level_entity_page()
    {
    
    $form_id = '3';
    //$entry = GFAPI::get_entries( $form_id );
    //var_dump($entry);
    /*
    foreach($entry[0] as $key => $value){
    echo "key = <br>".$key."<br>"."and value = <br>".$value."<br><br>";}
    if ($entry[0][5]=="???? ????"){
    echo "city is ???? ????";} else {echo 1;}
    */
    // echo strpos('123456','0');
    // if (strpos('saeb','s')){echo 1;}else {echo 2;}
    $search_criteria = array ('status'        => 'active',
        'field_filters' => array(
            'mode' => 'any',
            array(
                'key'   => '5',
                'value' => '???? ????'
            )
    ));
    $entries = GFAPI::get_entries( '3', $search_criteria );
    // foreach ($entries as $key => $value){
    // echo '<br>'.$entries[$key][5];
    // }
    $entry_list = [];
    
    for ($i = 0; $i < count($entries); $i++ )
    {
    	array_push ($entry_list,array(
    	$entries[$i]['id'],
    	$entries[$i]['date_created'],
    	$entries[$i]['1.3'],
    	$entries[$i]['1.6'],
    	$entries[$i][19],
    	$entries[$i][10],
    	$entries[$i][37]
    						));
    }
    ?>
    <table class="wp-list-table widefat fixed striped posts">
    	<thead>
    <tr>
    <td>
     "????? ???" 
     </td>
     <td>
    "?????"
     </td>
     <td>
    "???"
     </td>
    </tr>
    </thead>
    <tbody id="the-list">
    <?php
    
    for($i=0;$i < count($entry_list);$i++){
    echo "<tr><td><a href='".site_url()."/wp-admin/admin.php?page=gf_entries&view=entry&id=3&lid="
    .$entry_list[$i][0]."'>".$entry_list[$i][0]."</a></td><td>".
    "<a href='".site_url()."/wp-admin/admin.php?page=gf_entries&view=entry&id=3&lid="
    .$entry_list[$i][0]."'>".date_i18n( get_option( 'date_format' ), strtotime($entry_list[$i][1])).
    "</a></td><td><a href='".site_url()."/wp-admin/admin.php?page=gf_entries&view=entry&id=3&lid="
    .$entry_list[$i][0]."'>".$entry_list[$i][2]."</td></tr></a>";
    
    }
    ?></tbody></table><?php
    }
    
    ?>

    it works. till now,
    https://screenshots.firefox.com/7Djn73h2orDdJhEu/localhost

    but It doesnt have order by and limit item number per page

    my plugin code :
    https://beepaste.io/view/arU8dI
    array example :
    https://beepaste.io/view/VCYu1A
    I try to make table base of this:
    https://www.smashingmagazine.com/2011/11/native-admin-tables-wordpress/

    • This reply was modified 7 years, 4 months ago by czdah13.
    • This reply was modified 7 years, 4 months ago by czdah13.
    • This reply was modified 7 years, 4 months ago by czdah13.
    Thread Starter czdah13

    (@czdah13)

    sorry for my weak English , and I am beginner , actually this is my first time to write a plugin or even using php!

    Thread Starter czdah13

    (@czdah13)

    yes I just want to show them . but I want to can order them or filter the number of items per page,
    my array is like this :

    $entry_list = [];
    
    for ($i = 0; $i < count($entries); $i++ )
    {
    	array_push ($entry_list,array(
    	$entries[$i]['id'],
    	$entries[$i]['date_created'],
    	$entries[$i]['1.3'],
    	$entries[$i]['1.6'],
    	$entries[$i][19],
    	$entries[$i][10],
    	$entries[$i][37]
    						));
    }
    Thread Starter czdah13

    (@czdah13)

    Solved

    Thread Starter czdah13

    (@czdah13)

    problem solved

    .page-id-28 #page{
    background: url('https://leilafallah.axbabak.ir/en/wp-content/uploads/2016/03/bg5.jpg') no-repeat center center fixed;
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
      background-size: cover;
    }
Viewing 8 replies - 1 through 8 (of 8 total)