Forum Replies Created

Viewing 15 replies - 106 through 120 (of 144 total)
  • Plugin Contributor Babak Fakhamzadeh

    (@mastababa)

    Excellent!

    That requires a parameter, no? So, [namedirectory_single id=1]?

    Plugin Contributor Babak Fakhamzadeh

    (@mastababa)

    Great!

    Plugin Contributor Babak Fakhamzadeh

    (@mastababa)

    Here’s the code for the table listing the names in a directory:

        <table class="wp-list-table widefat name_directory_names fixed" cellpadding="0">
            <thead>
            <tr>
    	        <th width="5%"><?php echo __('ID', 'name-directory'); ?></th>
                <th width="5%"><?php echo __('Name', 'name-directory'); ?></th>
                <th width=""><?php echo __('Description', 'name-directory'); ?></th>
                <th width="5%"><?php echo __('Submitter', 'name-directory'); ?></th>
                <th width="10%"><?php echo __('Published', 'name-directory'); ?></th>
                <th width="10%"><?php echo __('Manage', 'name-directory'); ?></th>
            </tr>
            </thead>
            <tbody>
            <?php
            if(empty($name))
            {
                echo sprintf("<tr class='empty-directory'><td colspan='5'>%s</td></tr>",
                    __('Currently, there are no names in this directory..', 'name-directory'));
            }
    
            foreach($names as $name)
            {
                if(is_array($name))
                {
                    $name = (object)$name;
                }
    
                echo sprintf("
                <tr>
                    <td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><span title='%s' class='toggle_published' id='nid_%d' data-nameid='%d'>%s</span></td>
                    <td><a class='button button-primary button-small' href='" . $wp_url_path . "&edit_name=%d#anchor_add_form'>%s</a>
                        <a class='button button-small' href='" . $wp_url_path . "&delete_name=%d'>%s</a>
                    </td>
                </tr>",
                	$name->id,
                    $name->name, html_entity_decode(stripslashes($name->description)), $name->submitted_by,
                    __('Toggle published status', 'name-directory'), $name->id,
                    $name->id, name_directory_yesno($name->published),
                    $name->id, __('Edit', 'name-directory'),
                    $name->id, __('Delete', 'name-directory'));
            }
            ?>
            </tbody>
        </table>

    Here’s the function picking up one name by id:

    function name_directory_get_name($id)
    {
        global $wpdb;
        global $name_directory_table_directory_name;
    
    	$id = (int)$id;
    
        $names = $wpdb->get_results(sprintf("
    		SELECT *
    		FROM %s
    		WHERE <code>id</code> = $id",
            ARRAY_A
        );
    
        return $names;
    }

    And here’s the shortcode:

    function name_directory_show_name($attributes) {
    
        $dir = null;
        extract(shortcode_atts(
            array('id' => '0'),
            $attributes
        ));
    
        $names = name_directory_get_name($attributes["id"]);
    
        if (count($names) > 0) {
    	    $entry = (array)$names[0];
    	    $directory = name_directory_get_directory_properties($entry["directory"]);
    
            ob_start();
    
            echo '<div class="name_directory_name">';
            echo '<div class="name_directory_name_box">';
            echo '<a name="namedirectory_' . sanitize_html_class($entry['name']) . '"></a>';
            echo '<strong>' . htmlspecialchars($entry['name']) . '</strong>';
            if(! empty($directory['show_description']) && ! empty($entry['description']))
            {
                $print_description = html_entity_decode(stripslashes($entry['description']));
    
                /* This toggles the read more/less indicators, these need extra html */
                if(! empty($directory['nr_words_description']))
                {
                    $num_words = intval($directory['nr_words_description']);
                    $short_desc = name_directory_get_words($print_description, $num_words);
                    $print_description = str_replace($short_desc, "", $print_description);
                    if(! empty($print_description))
                    {
                        echo '<br /><div>
                          <input type="checkbox" class="name-directory-readmore-state" id="name-' . htmlspecialchars($entry['id']) . '" />
                          <span class="name-directory-readmore-wrap">' . $short_desc . ' <span class="name-directory-readmore-target">' . $print_description .'</span></span>
                          <label for="name-' . htmlspecialchars($entry['id']) . '" class="name-directory-readmore-trigger"></label>
                        </div>';
                    }
                    else
                    {
                        echo '<br /><div>' . $short_desc . '</div>';
                    }
    
                }
                else {
                    echo '<br /><div>' . $print_description . '</div>';
                }
            }
            if(! empty($directory['show_submitter_name']) && ! empty($entry['submitted_by']))
            {
                echo "<small>" . __('Submitted by:', 'name-directory') . " " . $entry['submitted_by'] . "</small>";
            }
            echo '</div>';
            echo '</div>';
    
            return ob_get_clean();
        }
    
    }
    add_shortcode('namedirectory_name', 'name_directory_show_name');
    Plugin Contributor Babak Fakhamzadeh

    (@mastababa)

    Oh, that’s nice. I’m actually marked as ‘Plugin contributor’. ??

    Plugin Contributor Babak Fakhamzadeh

    (@mastababa)

    How about that! This suddenly resolved itself, after, what, years!

    Plugin Contributor Babak Fakhamzadeh

    (@mastababa)

    Thanks!

    It’s a WordPress bug. My name also doesn’t show in the top right of this site when logged in. Even though my profile has the correct info.

    Plugin Contributor Babak Fakhamzadeh

    (@mastababa)

    Cool!

    Plugin Contributor Babak Fakhamzadeh

    (@mastababa)

    I see you pushed out a new release. I think I’m not the only one contributing to this release, right?

    You might want to consider adding the contributors to the list of “Contributors & Developers” at the bottom of the main plugin page.

    Plugin Contributor Babak Fakhamzadeh

    (@mastababa)

    You’re welcome ??

    Plugin Contributor Babak Fakhamzadeh

    (@mastababa)

    Understood.

    On your next update, consider adding the following function to shortcode.php. It adds a shortcode to display a random name.

    Use like this: [namedirectory_random dir=”2″]

    function name_directory_show_random($attributes) {
        $dir = null;
        extract(shortcode_atts(
            array('dir' => '1'),
            $attributes
        ));
    	
        $name_filter = array();
        $directory = name_directory_get_directory_properties($dir);
        $names = name_directory_get_directory_names($directory, $name_filter);
        $num_names = count($names);
    
    	if ($num_names > 0) {
    		$entry = $names[array_rand($names)];
    
    	    ob_start();
    
    		echo '<div class="name_directory_random_name">';
            echo '<div class="name_directory_name_box">';
            echo '<a name="namedirectory_' . sanitize_html_class($entry['name']) . '"></a>';
            echo '<strong>' . htmlspecialchars($entry['name']) . '</strong>';
            if(! empty($directory['show_description']) && ! empty($entry['description']))
            {
                $print_description = html_entity_decode(stripslashes($entry['description']));
    
                /* This toggles the read more/less indicators, these need extra html */
                if(! empty($directory['nr_words_description']))
                {
                    $num_words = intval($directory['nr_words_description']);
                    $short_desc = name_directory_get_words($print_description, $num_words);
                    $print_description = str_replace($short_desc, "", $print_description);
                    if(! empty($print_description))
                    {
                        echo '<br /><div>
                          <input type="checkbox" class="name-directory-readmore-state" id="name-' . htmlspecialchars($entry['id']) . '" />
                          <span class="name-directory-readmore-wrap">' . $short_desc . ' <span class="name-directory-readmore-target">' . $print_description .'</span></span>
                          <label for="name-' . htmlspecialchars($entry['id']) . '" class="name-directory-readmore-trigger"></label>
                        </div>';
                    }
                    else
                    {
                        echo '<br /><div>' . $short_desc . '</div>';
                    }
    
                }
                else {
                    echo '<br /><div>' . $print_description . '</div>';
                }
            }
    		if(! empty($directory['show_submitter_name']) && ! empty($entry['submitted_by']))
    		{
    			echo "<small>" . __('Submitted by:', 'name-directory') . " " . $entry['submitted_by'] . "</small>";
    		}
            echo '</div>';
    		echo '</div>';
    
    		return ob_get_clean();
    	}
    	
    }
    add_shortcode('namedirectory_random', 'name_directory_show_random');

    I noticed in another thread you just became a parent. Happy parenting! ??

    Thread Starter Babak Fakhamzadeh

    (@mastababa)

    Thanks for spotting, @ambroz.

    Indeed, having WordPress in an alternative location from the site URL breaks Gutenberg.

    The posted fix on the link you include did not work for me.

    Thread Starter Babak Fakhamzadeh

    (@mastababa)

    Hasn’t been resolved on my end either.

    I now get to see plenty of errors in the console. Like so:

    [Error] Failed to load resource: the server responded with a status of 403 () (autosaves, line 0)

    This, for:
    https://mysite.com/wp-json/wp/v2/posts/19890/autosaves?_locale=user

    I’d say .htaccess is not properly redirecting requests to my /wordpress folder.

    Thread Starter Babak Fakhamzadeh

    (@mastababa)

    I just got around to using the Health Check plugin. Disabling all plugins, then reenabling only Gutenberg resulted in exactly the same; editing a page with Gutenberg and saving the draft resulted in both a red banner saying ‘Updating failed’ and the status indicator stating ‘Saved’.

    Thread Starter Babak Fakhamzadeh

    (@mastababa)

    I’ll see what troubleshooting brings me and let you know.

    No, the content is not saved. I get a ‘saved draft’, or something like that, in my list of pages as a result.

    Thread Starter Babak Fakhamzadeh

    (@mastababa)

    I’ve installed the ‘health check & troubleshooting’ plugin, but I’m not at all clear how this could be helpful.

    I cleaned my .htaccess file of non-wp stuff (that is, old commented out lines). After this, Gutenberg both responded with ‘saved’ when pressing the ‘save draft’ button and ‘Updating failed’ (in red, underneath the header).

    Ii also started with an empty .htaccess file, letting WordPress and WP Fastest Cache fill the .htaccess file as they saw fit, but this resulted in the same situation: ‘saved’ and ‘updating failed’.

Viewing 15 replies - 106 through 120 (of 144 total)