<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mohamed atta</title>
    <description>The latest articles on DEV Community by mohamed atta (@matta).</description>
    <link>https://dev.to/matta</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F297391%2Fdee32898-62ea-4c31-b28c-4e1771961598.jpeg</url>
      <title>DEV Community: mohamed atta</title>
      <link>https://dev.to/matta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/matta"/>
    <language>en</language>
    <item>
      <title>Expandable WordPress post excerpt</title>
      <dc:creator>mohamed atta</dc:creator>
      <pubDate>Thu, 10 Mar 2022 16:27:34 +0000</pubDate>
      <link>https://dev.to/matta/expandable-wordpress-post-excerpt-561o</link>
      <guid>https://dev.to/matta/expandable-wordpress-post-excerpt-561o</guid>
      <description>&lt;p&gt;&lt;strong&gt;First the PHP&lt;/strong&gt;&lt;br&gt;
Add this function in function.php&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function expandable_excerpt($excerpt)
{
    $split = explode(" ", $excerpt); //convert string to array
    $len = count($split); //get number of words
    $words_to_show_first = 19; //Word to be dsiplayed first
    if ($len &amp;gt; $words_to_show_first) { //check if it's longer the than first part

        $firsthalf = array_slice($split, 0, $words_to_show_first);
        $secondhalf = array_slice($split, $words_to_show_first, $len - 1);
        $output = '&amp;lt;p class="event-excerpt" &amp;gt;';
        $output .= implode(' ', $firsthalf) . '&amp;lt;span class="see-more-text"&amp;gt;...see more&amp;lt;/span&amp;gt;';

        $output .= '&amp;lt;span class="excerpt-full hide"&amp;gt;';
        $output .= ' ' . implode(' ', $secondhalf);
        $output .= '&amp;lt;/span&amp;gt;';
        $output .= '&amp;lt;/p&amp;gt;';
    } else {
        $output = '&amp;lt;p class="event-excerpt"&amp;gt;'  .   $excerpt . '&amp;lt;/p&amp;gt;';
    }
    return $output;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Required CSS&lt;/strong&gt;&lt;br&gt;
CSS to simply hide elements when needed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.excerpt-full.hide {
display: none;
}
.see-more-text.hide {
display: none;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Required JS&lt;/strong&gt;&lt;br&gt;
script to add/remove css classes when needed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const itemSeeMore = document.querySelectorAll(
  "p.event-excerpt&amp;gt; span.see-more-text"
);
if (itemSeeMore) {
  itemSeeMore.forEach((item) =&amp;gt; {
    item.addEventListener("click", () =&amp;gt; {
      item.classList.toggle("hide");
      item.nextElementSibling.classList.toggle("hide");
    });
  });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the function in simple shortcode example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function display_post()
{
    $rand_post = get_post('7');
    print_r($rand_post);
    $output = '&amp;lt;div class="post-wrapper"&amp;gt;';
    $output .= '&amp;lt;h2&amp;gt;' . $rand_post-&amp;gt;post_title . '&amp;lt;/h2&amp;gt;';
    $output .= expandable_excerpt($rand_post-&amp;gt;post_excerpt);
    $output .= '&amp;lt;/div&amp;gt;';

    return $output;
}
add_shortcode('display_post', 'display_post');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the short code &lt;code&gt;[display_post]&lt;/code&gt; in you page editor&lt;/p&gt;

&lt;p&gt;And that's it, thanks for reading the article if you want any support on it just let me know. &lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>php</category>
      <category>javascript</category>
      <category>css</category>
    </item>
    <item>
      <title>Use mobile camera as a webcam</title>
      <dc:creator>mohamed atta</dc:creator>
      <pubDate>Mon, 21 Dec 2020 19:28:04 +0000</pubDate>
      <link>https://dev.to/matta/use-mobile-camera-as-a-webcam-101l</link>
      <guid>https://dev.to/matta/use-mobile-camera-as-a-webcam-101l</guid>
      <description>&lt;p&gt;So You have an important meeting, interview, or family gathering and you have a bad built-in laptop camera.&lt;/p&gt;

&lt;p&gt;you can use your mobile camera as a webcam&lt;br&gt;
It's very easy you need to &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;install Iriun Webcam software from this link on your both mobile
and laptop &lt;a href="https://iriun.com/" rel="noopener noreferrer"&gt;Link&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;connect both devices on the same network or view USB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;that's it good luck with your next meetings&lt;/p&gt;

</description>
      <category>zoom</category>
      <category>meeting</category>
      <category>webcam</category>
      <category>hacks</category>
    </item>
  </channel>
</rss>
